Strange error_page behavior
Fabiano Furtado Pessoa Coelho
fusca14 at gmail.com
Fri Aug 7 00:43:46 UTC 2020
Hi...
I have the following setup in my NGINX 1.18.0 server:
http {
...
error_page 400 /my400.html;
error_page 401 /my401.html;
error_page 403 /my403.html;
error_page 404 /my404.html;
error_page 405 /my405.html;
error_page 413 /my413.html;
error_page 500 /my500.html;
error_page 502 503 /my503.html;
error_page 504 /my504.html;
...
server {
...
allow 10.0.0.0/8; # my internal network
deny all; # all others networks
error_page 403 =503 /my503.html;
#error_page 502 503 /my503.html;
location ~ ^/(my400|my401|my403|my404|my405|my413|my500|my503|my504)\.html$
{
root /usr/share/nginx/my_custom_error_pages;
internal;
allow all;
}
...
location / {
...
proxy_pass http://...;
}
}
}
In this setup, I want to allow my internal network to access my
backend server via proxy_pass AND deny this access to others networks
(error 403 "redirected" to 503 --> defined in "error_page 403 =503
/my503.html;").
This is working great, but when my backend gets down, I receive a
default NGINX "502 Bad Gateway" error page instead of my custom
my503.html page.
Why this is happening?
I can solve this issue uncommenting the "#error_page 502 503
/my503.html;" line in server block, but this configuration is already
defined in http block, which is hierarchically superior in comparison
with server block. Why NGINX isn't regarging the error_page in http
block?
Thanks in advance.
More information about the nginx
mailing list