Welcome! Log In Create A New Profile

Advanced

Strange error_page behavior

Fabiano Furtado Pessoa Coelho
August 06, 2020 08:46PM
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.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Strange error_page behavior

Fabiano Furtado Pessoa Coelho August 06, 2020 08:46PM

Re: Strange error_page behavior

Francis Daly August 07, 2020 03:06AM

Re: Strange error_page behavior

Fabiano Furtado Pessoa Coelho August 07, 2020 09:32AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 47
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready