I have NGINX set up as a reverse proxy, which works fine. In the event
my web server goes down, I would like NGINX to act as the failover, and
serve a local page with just some basic company information and a “check
back soon” type message. Trying to do this, I think I’m getting stuck
in an infinite loop and always end up with a 502 Gateway error. For
testing, I was just trying to get it working with generic load
balancing, going back and forth between my web server and the local
NGINX “Check Back Soon” page. My config looks something like this:
upstream Server_Test {
server 123.456.789.001;
server 127.0.0.1;
}
server {
listen
123.456.789.002;
server_name
www.test.com;
location / {
proxy_pass http://Server_Test;
proxy_next_upstream error timeout
invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host
$host;
proxy_set_header X-Real-IP
$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
}
}
server {
listen
127.0.0.1;
server_name
www.test.com;
location / {
root html;
index index.html
index.htm;
}
}
Any reason why this shouldn’t work?
Thanks!
Jason