Nginx

From Leaky
Revision as of 23:03, 23 January 2014 by Leaky (talk | contribs) (Using nginx as a proxy during server migrations)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To use nginx as a proxy - for example from an old server to a new one during a migration, you need to set the Host header to be $host

There are also some other headers that could be useful so just set the whole lot in the global part of /etc/nginx/conf.d/default.conf

proxy_set_header    Host                $host;
proxy_set_header    Connection          "";
proxy_set_header    X-Real-IP           $remote_addr;
proxy_set_header    X-Forwarded-Port    $server_port;

Setup the server to listen either on every interface port 80, or a specific IP on port 80 using the listen directive.

server {
   listen      80 default_server;
   listen      [2a02:af8:3:2000::7982]:80 default_server;
   server_name _;

And make sure that the entire site from / downwards is proxied through to the new IP address

   location / {
       proxy_pass http://213.229.84.27;
   }
}