views:

35

answers:

1

I currently use nginx with passenger to serve my rails app. considering including a caching reverse proxy to the equation. Can I use the same instance of nginx as a reverse proxy (running on port 80, serving static as well as e-tagged actions) as well or would I need a different instance of nginx or a totally different type of reverse proxy?

Thanks!

A: 

I think You can use the same instance of NGINx to do both but You will have to configure your application to listen on a different port. You can run your application on port 8080 listening to localhost only and the reverse proxy on the port 80.

A server part of your nginx configuration might look like this

server {
  listen 127.0.0.1:8080;
  server_name localhost;
  root /webapps/foo.com/public;
  passenger_enabled on;
}

server {
  listen 80;
  server_name www.foo.com;
  location / {
    proxy_pass http://127.0.0.1:8080;
  }
}

Please do not nail me on the exact syntax, this is just to show the Idea.

Hope this helps.

Pavlo