Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have got two servers (A and B) with NGINX. Server A is serving old site and server B is serving a new site. I've updated my DNS but it is quite slow: in my office I still see my old site:

How can I redirect all requests from server A for this particular subdomain to server B?

Now they both are handled with this in NGINX:

server {
  listen 80;
  root /var/www/subdomain/public;
  passenger_enabled on;
share|improve this question
up vote 3 down vote accepted

Since they're both using the same server_name, you can't do a simple redirection.

You can probably do some sort of proxy, though, along the lines of the following on the old server:

upstream newserver {
  server;  # this is new server, by IP address

server {
  listen 80;
  location / {
    proxy_set_header Host $host;
    proxy_pass http://newserver;

So, basically, configure the old server so that it will pass all requests to the new server. Of course, put in whatever configuration you'll need for client_max_body_size and all that.

share|improve this answer
How can this be done using SSL? Does the proxy machine need the ssl certificate as well as the upstream server? – earthmeLon Apr 22 '13 at 8:39
@earthmeLon In the original question, this proxy was a temporary measure for the DNS update. In that case, both new and old servers would have the SSL certificate. In the case of the upstream, you can connect over SSL or over plain HTTP; since you control both boxes, it'd be up to your preference. – cjc Apr 22 '13 at 14:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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