NGINX mail proxy logging

Please use this template for troubleshooting questions.

My issue: Does mail proxy have logging?

How I encountered the problem: logging directives not allowed in mail block

Solutions I’ve tried: Attempted to put access_log into mail block

Version of NGINX or NGINX adjacent software (e.g. NGINX Gateway Fabric): 1.20

Deployment environment: alma linux 9

Minimal NGINX config to reproduce your issue (preferably running on https://tech-playground.com/playgrounds/nginx for ease of debugging, and if not as a code block): (Tip → Run nginx -T to print your entire NGINX config to your terminal.)

NGINX access/error log: (Tip → You can usually find the logs in the /var/log/nginx directory.)

hello - I am using nginx as a reverse mail proxy for imap, pop, and smtp. I would like to log mail proxy requests for troubleshooting and security purposes. As an example I would like to log authentication errors (client IP, username attempted, perhaps a couple of other things) - and feed this into fail2ban so that brute force password attempts can be blocked. I tried placing access_log directive into the mail{} block without success. Is there a way to enable logging in the mail proxy module or http authentication module?

The authentication endpoint receives all the information about an incoming request.

Idiomatic approach is to use auth request pointed at the same instance of nginx (and possibly proxy them elsewhere after this). You can then log anything you need (including client IP and auth result) in http part and use http logs for fail2ban.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.