In my Nginx config I have some IP blocks in place, to fight off spammers & bots.
This is very effective, but as a result, my error logs get filled up super fast with error messages like these:
2015/12/16 00:56:28 [error] 27748#0: *120462 access forbidden by rule, client: 167.114.xxx.xxx, server: bla bla ....
Now I don't want to fully disable error logging, as I want to find out what is going wrong when something goes wrong. I just want to disable logging of these "forbidden by rule" messages.
Any idea how to do this?
As mentioned here, use conditional logging (
access_log
directive):Enabling Conditional Logging
EDIT: as @zsero described in comment, conditional logging is only supported with the
access_log
- not with theerror_log
directive.There is better solution, suggested by upstream - to use geo block with if to reject requests like:
I used this nginx config to ignore malicious requests on hidden files:
Returning a 444 (Connection Closed Without Response) closes the connection and doesn't log any error.