I'm trying to create a fallback for my error_page. Basically, the logic should be something like the following:
- load foobar.html
- does not exist on remote server -> load 404.html from remote server to show 404 page
- does not exist on remote server -> load 404.html on local filesystem
Loading both localhost/404.html and localhost/global404.html works, but when I break localhost/404.html (by removing the file from the http server) it does not show the global404.html page as I'd expect.
server { listen 80; server_name example.com www.example.com; proxy_intercept_errors on; location / { proxy_pass http://localhost:3000; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; error_page 404 /404.html; } location /404.html { proxy_pass http://localhost:3000/404.html; error_page 404 /global404.html; } location /global404.html { root /usr/share/nginx/html; } } The above works fine when I hit http://localhost/404.html (when the 404.html file is on the remote server it shows that, when I delete the file it loads the global404.html file).
However, when I type a non-existent page I just get the default nginx 404 page.
error_pagedoes not cascade. So while Nginx is processing anerror_pageit will not allow anothererror_pageto trigger. As both of the errors are triggered remotely, I can't see any viable solution.try_filesmight be useful but it seems it'll only serve static files and there is no way to get it to proxy.