Forum: NGINX Disable Reverse Proxy for Failover

447cb72b64b7140a092797cbb7fe541b?d=identicon&s=25 Hect, Jason (Guest)
on 2014-04-23 23:59
(Received via mailing list)
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
A8108a0961c6087c43cda32c8616dcba?d=identicon&s=25 Maxim Dounin (Guest)
on 2014-04-24 13:22
(Received via mailing list)
Hello!

On Wed, Apr 23, 2014 at 09:58:48PM +0000, Hect, Jason wrote:

> 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:

[...]

> Any reason why this shouldn't work?

Looking into logs might be a good idea.

--
Maxim Dounin
http://nginx.org/
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.