Puneet Arora
Puneet Arora

Reputation: 45

Have custom Nginx error page when All backend servers unhealty

I am using Nginx Plus AWS EC2 image for my production environment. I use the health checks module to see the availability of backend servers. When all the servers are unhealthy. Then nginx returns a 404 error screen.

I am unable to find the HTML for that. I need to configure that.

Any ideas how can I find that ?

Thanks

Upvotes: 0

Views: 562

Answers (1)

Patrick Nommensen
Patrick Nommensen

Reputation: 36

You can use proxy_next_upstream [1] to specify case when the request be passed to the next backend, e.g. 502 error, etc. When the backend is unavailable, or all of them are unvailable when using proxy_next_upstream, a 502 error will be returned. You can specify which file is served in this situation.

location / {
        proxy_pass http://backend;
        error_page 502 /50x.html;
    }

Define location for 50x.html, otherwise it will go back to the "/" location.

location /50x.html {
    }

[1] http://nginx.org/r/proxy_next_upstream

Note: NGINX Plus comes with commercial support. To access support visit http://nginx.com/ami-support-activation and enter your AWS Account Number.

Upvotes: 1

Related Questions