I’m studying about in the use of upstream in the nginx. And I have a
question about the condition of use it.
Now, I have the following environment in production:
Internet – > Nginx → Varnish → Apache
I would like of set in upstream a backup’s server, for example:
upstream backend {
ip_hash;
server 192.168.1.5:6081; # varnish server
server 192.168.1.7:80 backup; # apache server
}
But in the case the configuration of the “location /” will change
according
with the server.
Is there some parameter of condition that I can used?
Just to complete the information, in my case I have two configuration
according with the web server, so:
TO VARNISH
location / {
proxy_redirect off; # Do not redirect this proxy - It needs to be
pass-through
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Server-Address $server_addr;
proxy_connect_timeout 5s;
proxy_read_timeout 300s;
proxy_pass_header Set-Cookie;
proxy_pass http://localhost:6081; # Pass all traffic through to
Varnish
}