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.
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.
On
The accepted answer was not working for me.
I fixed this by adding a slash at the end of the index directive like so:
index index.htm index.html index.php /;
The way this works is I guess by looking for nothing in the root directory, not finding it and reporting a genuine 404. It can be any bogus page with a slash before, such as /404.html or /this_file_isnt_really_there or whatever.
What it does is to suppress 403 errors altogether, as if the directory weren't there at all, so there's no reason to log.
This comes with the advantage of hardening the installation, actual folder paths can no longer be identified.
However, I'm not sure how valid, safe or futureproof this approach may be, so use at your own peril.
Something like log_not_allowed would be much nicer i guess.
Theoretically, you can specify a named location to handle
403and disable error logging there:Doesn't have to be a named location though: