Using the access_log if directive in 1.6.x
Valentin V. Bartenev
vbart at nginx.com
Thu Dec 11 18:39:41 UTC 2014
On Thursday 11 December 2014 13:25:45 sudharshanr wrote:
[..]
>
> Hello Valentin,
>
> Thank you for your reply. Just one question. It is not just the 404 errors
> that I want to redirect. I want to redirect all 4xx and 5xx errors. I have
> updated my config file as below, but it doesn't seem to work. The 404 errors
> still go to access.log
>
> server {
> ...
> ...
> root /wdrive/www;
>
> access_log /mnt/log/nginx/access.log ;
> error_log /mnt/log/nginx/error.log;
>
> error_page 400 401 402 403 404 /error4x.html;
> error_page 500 501 502 503 /error5x.html;
>
> location /error4x.html{
> access_log /mnt/log/nginx/error.log;
> }
>
> location /error5x.html{
> access_log /mnt/log/nginx/error.log;
> }
>
> location / {
> ....
> }
> }
>
> I have created error4x.html page in /wdrive/www.
>
> Thanks.
>
By default, the errors generated by nginx itself are only handled
by the error_page directive. If you want to intercept errors from
upstream as well then you need to turn on proxy_intercept_errors.
See the docs: http://nginx.org/r/proxy_intercept_errors
It's always a good idea to provide your full configuration with
a question.
wbr, Valentin V. Bartenev
More information about the nginx
mailing list