So our server setup goes like this:
www <-> nginx <-> backend services
The internal services require authorisation, which often fails with a 403 if a user's token is incorrect and so forth.
Now, we also use fail2ban
which keeps an eye on nginx's error.log files for something fishy and bans IP's for a certain amount of time.
What I'd like to achieve here is have nginx log an error when the backend services return a 403, so that if there are excess 403's fail2ban
can ban the IP address for the next ten minutes or so. Currently, nginx doesn't log anything to the error.log file if a backend service responds with a 403.
How can that be done? Thanks.