According to the doc: http://wiki.nginx.org/HttpFastcgiModule#fastcgi_in... Note: You need to explicitly define the error_page handler for this for it to be useful. As Igor says, "nginx does not intercept an error if there is no custom handler for it it does not show its default pages. This allows to intercept some errors, while passing others as are." Actually I still can't understand the exact meaning, so I have done some experimentd. 1. turn on fastcgi_intercept_errors, - in the backend php/fcgi send 404 header, - set the error_page (php) Result: nginx use the default error template 2. turn off fastcgi_intercept_errors, - in the backend php/fcgi send 404 header - set the error_page (php) Result: now the custom error_page (php) is being used. So it seems to me that* fastcgi_intercept_errors should be off and set the error_page *if I need to specify custom error handler, is this interoperation correct? Thanks.
on 2012-11-05 18:12
on 2012-11-09 04:34
Hello! On Tue, Nov 06, 2012 at 01:12:05AM +0800, howard chen wrote: > > Result: now the custom error_page (php) is being used. It's unclear how you did your experiments, but results are all wrong - most likely, you missed something. E.g. in (1) I would assume request to the error_page resulted in another 404, which in turn resulted in default error page returned. > So it seems to me that* fastcgi_intercept_errors should be off and set > the error_page *if I need to specify custom error handler, is > this interoperation correct? No. The fastcgi_intercept_errors directive is off by default, and this means that nginx won't try to do anything with responses returned by backends as long as they are valid. If you want nginx to change response returned by a backend, you have to switch on fastcgi_intercept_errors and configure appropriate error_page. Example configuration: error_page 404 /errors/404.html; location / { fastcgi_pass 127.0.0.1:9000; fastcgi_intercept_errors on; ... } location /errors/ { # static } With the above config if fastcgi backend returns 404, the /errors/404.html will be returned instead (assuming it exists). -- Maxim Dounin http://nginx.com/support.html
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.