之前一直在用 haproxy,但是似乎总会死掉,要定期重启才可以。这次直接换成 nginx 了。
本次以 mailgun.com 的 SMTP 服务举例,在 nginx 配置好后,到需要发信的服务器,使用 hosts 将 smtp.mailgun.org 域名指向到代理的服务器 IP 即可。
直接贴配置:
stream {
log_format proxy '$remote_addr [$time_local] '
'$protocol $status $bytes_sent $bytes_received '
'$session_time "$upstream_addr" '
'"$upstream_bytes_sent" "$upstream_bytes_received" "$upstream_connect_time"';
server {
listen 25;
proxy_pass smtp.mailgun.org:25;
access_log /www/wwwlogs/access.stream.log proxy;
}
server {
listen 465;
proxy_pass smtp.mailgun.org:465;
access_log /www/wwwlogs/access.stream.log proxy;
}
server {
listen 587;
proxy_pass smtp.mailgun.org:587;
access_log /www/wwwlogs/access.stream.log proxy;
}
server {
listen 2525;
proxy_pass smtp.mailgun.org:2525;
access_log /www/wwwlogs/access.stream.log proxy;
}
}
记得添加防火墙白名单:
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="8.8.8.8/24" accept"
firewall-cmd --reload
怎么弄呀,我没明白