Serving default error pages with 'proxy_intercept_errors on'

Maxim Khitrov max at mxcrypt.com
Fri Dec 27 20:47:51 UTC 2013


Hello,

I'm running nginx v1.4.1 on OpenBSD 5.4 and I'd like to use
'proxy_intercept_errors on' directive without providing my own error
pages. In other words, instead of forwarding page content from the
backend server, just use the error pages that nginx generates by
default.

This isn't supported normally, however the following configuration
seems to achieve the desired result (though you have to list the error
codes explicitly):

error_page 403 404 ... @error;
location @error { return 444; }

I didn't actually know what this would do until I tried it. I assume
that when a matching error code is received from the backend server,
nginx closes the proxy connection without reading the body and creates
a new internal request to @error, which is immediately closed without
a response. Thus, there is no body to send to the client, so it falls
back to the default behavior.

The question is whether this behavior is an accident and may change in
a future version, or if it's an acceptable way of intercepting errors
without providing custom error pages?

- Max



More information about the nginx mailing list