nginx default error page stopped working for some reason

davidhq asked:

This used to work:

server {

  location / {
    proxy_pass http://localhost:8888;
    error_page 502 /502.html;

  location = /502.html {
    root /var/www/example;

Now suddenly it doesn’t anymore… I don’t know what changed ?

I get 404 instead of displayed /var/www/example/index.html in case port 8888 doesn’t respond…

How to make this work again?
thank you

My answer:

Your configuration states that the error document is /var/www/example/502.html. Nothing in your configuration attempts to load /var/www/example/index.html at any time, ever. Rename the file.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.