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

Yusuf Goolamabbas yusufg at
Thu Jun 15 08:44:49 MSD 2006

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/ ;

More information about the nginx mailing list