nginxhttp-status-code-403nginx-log

Disable Nginx logging of 403 errors


Is it possible to stop Nginx logging 403 errors?

I am using the directive:

error_log /var/www/error.log;

You can use log_not_found to stop the logging of 404s, but I can't see a way to stop the logging of 403s.


Solution

  • Theoretically, you can specify a named location to handle 403 and disable error logging there:

    error_page 403 = @403_handler;
    location @403_handler {
        error_log /dev/null;
    }
    

    Doesn't have to be a named location though:

    error_page 403 /403.html;
    location = /403.html {
        error_log /dev/null;
    }