Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to use Nginx on my personal VPS to act as a reverse proxy in front of Heroku (running a Ruby on Rails app)?

I'd like to do this because I want to route standard requests (i.e. GET to my Rails app, but various subdomain requests (i.e. GET to a separate server.

As a bit of a part 2 (assuming this is possible), what are the correct Nginx proxy headers to set in this case? I usually do the following when using Nginx in front of Unicorn:

proxy_redirect off;
proxy_read_timeout 5m;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-Proto  http;

As it is in nearly every single tutorial, but I'm not knowledgable enough to know which apply (or are missing) in this case.

Help would be greatly appreciated!

share|improve this question

closed as off topic by mdpc, Khaled, kce, mgorven, longneck Feb 4 '13 at 19:19

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

up vote 3 down vote accepted

It is possible to do what you are proposing through proxy_pass ( but it would be easier to route these requests through DNS.

To use the apex domain for Heroku, you can use ALIAS records at DNSimple or ANAME records at DNS Made Easy and regular A records for your subdomains.

However, my own site has the domain apex set to A record to nginx, which straight up redirects to www, which is a CNAME to heroku. More about what is supported/suggested is here:

share|improve this answer
Agreed. The only reason for doing something like this not through DNS is if you need the flexibility to make different paths go to different servers (i.e., -> server A, -> server B). – Scrivener Feb 3 '13 at 19:13
Sounds like it makes sense. I'll give this a try and report back! Thanks. – Brandon Feb 3 '13 at 21:41

Not the answer you're looking for? Browse other questions tagged or ask your own question.