大网数据广告活动
服务器运维问答

how to configure postfix behind haproxy?

· 52CE 我爱测

During the last years I had an emailserver running for my small business without problems. Now that my company has grown, I wanted to add a bit of redundancy and added a failover emailserver with a loadbalancer in front (haproxy)…

问题原文

原帖链接 · Joe Silencio · CC BY-SA 4.0

During the last years I had an emailserver running for my small business without problems.

Now that my company has grown, I wanted to add a bit of redundancy and added a failover emailserver with a loadbalancer in front (haproxy).

All went fine until 1 week ago when we fell victim to spammers and i had to shut down everything. Using google a lot, I found out that a loadbalancer without the correct config converts my postfix into an open relay.

I would like to solve this and also found a lot of docs, but frankly now I'm a bit lost. I know that I have to add send-proxy in haproxy.cfg amongst other changes, but I just can't figure out how to add postscreen in order to harden postfix again.

Could anyone guide me or at least give me some link which I haven't found to a manual or tutorial of how this could be achieved?

I admit that I'm getting lost in the postfix official docs.

Many thanks in advance

社区高分解答

原帖链接 · Christopher Thomas · CC BY-SA 4.0

Maybe this helps somebody out. The configuraton of haproxy I do differently because I'm running inside a kubernetes cluster. But the configuration of postfix, you update two files, accordingly

master.cf

# Exposed SMTP service (postscreen support is needed to support the proxy protocol [search postscreen_upstream_proxy_protocol in main.cf])
smtp      inet  n       -       -       -       1       postscreen
smtpd     pass  -       -       -       -       -       smtpd

main.cf

# This is required to support the proxy protocol to acquire the correct source ip address from whoever is connecting to this server
# It's really important to get this information because otherwise ALL your connections will come from your internal ip address
# Guess what you allow to send emails, without question? Thats right! You're $mynetworks. Which means because you cannot get the
# correct source ip address, it permits EVERYBODY TO SEND EMAIL THROUGH YOUR SERVER! You basically become an open relay
postscreen_upstream_proxy_protocol = haproxy
postscreen_upstream_proxy_timeout = 5s

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2018-07-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。