Following is a sample Nginx server configuration. Without the "magical talisman" location block, proxied error content results in an Nginx 404 page rather than the customized error page being served.
Removing the proxy_intercept_errors directive serves a proper proxied error page with proper http error code headers.
Nonproxied error pages are rendered properly regardless of the presence of the magical talisman.
Any ideas as to what exactly is going on?
server {
server_name mydomain.com "";
listen 80;
root /var/www;
error_page 400 401 402 403 404 500 501 502 503 504 /admin/error_page.htm;
proxy_intercept_errors on;
location /proxy/ {
proxy_read_timeout 60s;
proxy_set_header Host $host;
proxy_pass http://myservers;
}
location /test404/ {
return 404;
}
location /admin/ { # this line constitute a magical talisman that fixes proxied error interception(???)(!)
rewrite ^(/admin)(.*)$ /admin$2 break;
}
}