Can error_pages be used to intercept a 404 response from an upstream backend

Igor Sysoev is at rambler-co.ru
Fri Jun 16 09:21:13 MSD 2006


On Thu, 15 Jun 2006, Yusuf Goolamabbas wrote:

> Hi, I have been able to use error_page for error code 502,503,504 when
> nginx is used as a reverse proxy.
> Is it possible to use error_page to handle 403,404 responses from the
> upstream and replace it with an error_page specifed in nginx
>
> I tried to use the following
>
> error_page  404  /40x.html;
>        location /40x.html {
>            root /tux/ ;
>        }
>
> But when I request the URL (which doesn't exist), I get the response
> generated by the upstream backend server
>
> The corresponding stanza for 50x codes work correctly (when the
> upstream backend is not answering)
>
> error_page  502 503 504  /50x.html;
>      location /50x.html {
>        root /tux/ ;
>      }

You should set "proxy_redirect_errors  on" for proxied locations:

     location / {
         proxy_redirect_errors  on;
         proxy_pass  ...
     }


Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list