Strange error_page behavior

Francis Daly francis at
Fri Aug 7 07:05:00 UTC 2020

On Thu, Aug 06, 2020 at 09:43:46PM -0300, Fabiano Furtado Pessoa Coelho wrote:

Hi there,

> http {
>   error_page 502 503 /my503.html;
>   ...
>   server {
>     ...
>     error_page 403 =503 /my503.html;
>     #error_page 502 503  /my503.html;

> 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?

Nginx directive inheritance is (in general) "by replacement" or "not
at all".

If you have a directive in a location, that is the full set of
that-directives that applies to the matching request.

Since you have an error_page at server{} level, any error_page defined
at http level is irrelevant for any request handled in this server{}.

If you want a distinct set of error_page directives to apply at
server{}-level, you must write them all there (perhaps by "include"ing
a file).

Francis Daly        francis at

More information about the nginx mailing list