I set up an exim server in a Debian 10 container with LXD and then created a proxy device to map the SMTP port from the host to the container:
lxc config device add mycontainer myport25 proxy listen=tcp:x.x.x.x:25 connect=tcp:127.0.0.1:25
where x.x.x.x is the host's public IP.
The port forwarding is working fine but, as I expected, the exim logs are showing the local IP instead of the remote servers ones. For example:
2020-10-07 13:45:40 1kQ7t6-0008P1-3M <= [email protected] H=localhost (server.remote.domain.com) [127.0.0.1] P=esmtps X=TLS1.0:RSA_AES_256_CBC_SHA1:256 CV=no S=14259 [email protected]
2020-10-07 13:45:40 1kQ7t6-0008P1-3M => |/usr/local/bin/script.php [email protected] R=myrouter T=myrouter_pipe 2020-10-07 13:45:40 1kQ7t6-0008P1-3M Completed
Is it possible to get exim to show in the logs the forwarded IP instead of 127.0.0.1?
I read https://www.exim.org/exim-html-current/doc/html/spec_html/ch-proxies.html but if I use the hosts_proxy option, my server rejects incoming emails with this error: "503 Command refused, required Proxy negotiation failed".
I know I can forward the port using plain iptables in the host and the private IP of the container but I wonder if I can do it using the proxy feature of LXD.
Regards,
Ok, I do apologize. I forgot to add the proxy_protocol=true to the command that creates the proxy:
Now the exim logs show the sender server IP:
2020-10-07 16:45:21 1kQAgz-0000Hk-4g => |/usr/local/bin/mailgate.php [email protected] R=myrouter T=mytransport_pipe 2020-10-07 16:45:21 1kQAgz-0000Hk-4g Completed