Error_page x 2?

Can you intercept errors twice? I tried something like the following,
but it still serves the nginx 404 page. Is there a better way?

server {
root /data;

error_page 404 = /fetch$uri;

location /fetch {
internal;
proxy_pass http://backend;
proxy_intercept_errors on;
alias /data;
error_page 404 /404.html;
}
}

On Mon, Dec 17, 2007 at 11:08:43PM -0800, Eden Li wrote:

Can you intercept errors twice? I tried something like the following,
but it still serves the nginx 404 page. Is there a better way?

Yes, “recursive_error_pages on”.

error_page 404 /404.html;

}
}

Use the following configuration:

 location / {
     root /data;
     error_page 404 = @fetch;
 }

 location @fetch {
     internal;

     proxy_pass http://backend;
     proxy_intercept_errors on;

     recursive_error_pages  on;
     error_page 404 /404.html;
 }