This used to work:
server {
server_name example.com;
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
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.The majority of your content lives on the remote server. You need to serve an error page (together with some resources) locally. You need a "special location" which is distinct from any location served from upstream, and put all of your local resources in there. I can't pick a name for that location, as I have no idea what you are serving from 8888. But lets say
/error_pages
for now.With the above configuration, you will need to edit
502.html
and change the URLs of the resources to add the/error_pages
prefix.You will also need to move all of the files (
502.html
and its resource files) into/var/www/example/error_pages/
subdirectory.