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.
server {
server_name example.com;
location / {
proxy_pass http://localhost:8888;
error_page 502 /error_pages/502.html;
}
location /error_pages {
root /var/www/example;
}
}
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.