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:

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 <= sender@remote.domain.com H=localhost (server.remote.domain.com) [] P=esmtps X=TLS1.0:RSA_AES_256_CBC_SHA1:256 CV=no S=14259 id=d0c331c0-2cb8-ac64-c75c-1cede50a6815@remote.domain.com

2020-10-07 13:45:40 1kQ7t6-0008P1-3M => |/usr/local/bin/script.php mailproxy@local.domain.com 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

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.



Ok, I do apologize. I forgot to add the proxy_protocol=true to the command that creates the proxy:

lxc config device add mycontainer myport25 proxy listen=tcp:x.x.x.x:25 proxy_protocol=true connect=tcp:

Now the exim logs show the sender server IP:

2020-10-07 16:45:21 1kQAgz-0000Hk-4g <= sender@remote.domaincom H=host.remote.domain.com [public_ip_here] P=esmtps X=TLS1.0:RSA_AES_256_CBC_SHA1:256 CV=no S=14249 id=f4545bc8-763c-1553-fe62-be61439fe23f@remote.domain.com

2020-10-07 16:45:21 1kQAgz-0000Hk-4g => |/usr/local/bin/mailgate.php mailproxy@local.domain.com R=myrouter T=mytransport_pipe 2020-10-07 16:45:21 1kQAgz-0000Hk-4g Completed

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.