Port forwarding postfix

Hi,

I’ve just setup a containerized postfix / dovecot server and I’m struggling to get the client IP instead of the localhost IP when I send email from my client mail to the server. Plus, if I do not set localhost in the network parameters of the port forward, I have an error about SSL and the connection gets rejected.

Postscreen is already setup so when I receive mail from other server I do get the client ip and the email.

smtp_port:
    connect: tcp:10.202.193.120:25
    listen: tcp:0.0.0.0:25
    proxy_protocol: "true"
    type: proxy
submission_port:
    connect: tcp:127.0.0.1:587
    listen: tcp:0.0.0.0:587
    type: proxy
postfix/submission/smtpd[361]: setting up TLS connection from localhost[127.0.0.1]

Non localhost config with proxy_protocol enabled :

smtp_port:
    connect: tcp:10.202.193.120:25
    listen: tcp:0.0.0.0:25
    proxy_protocol: "true"
    type: proxy
submission_port:
    connect: tcp:10.202.193.120:587
    listen: tcp:0.0.0.0:587
    proxy_protocol: "true"
    type: proxy
postfix/submissions/smtpd[683]: setting up TLS connection from emailstack.lxd[10.202.193.120]
postfix/submissions/smtpd[683]: SSL_accept error from mail.lxd[10.202.193.120]: -1
postfix/submissions/smtpd[683]: warning: TLS library problem: error:0A00010B:SSL routines::wrong version number:../ssl/record/ssl3_record.c:354

I had the same error with dovecot when haproxy was not set in conf file.

Thanks for your help !

You should probably use proxy with NAT mode to fix this issues to avoid much hassle (I remember having some issue sometimes with TLS and proxy protocol depending on the application)

Thanks @ruskofd nat mode solved this issue.

1 Like