根据端口重定向到后端

时间:2014-12-18 23:57:59

标签: haproxy

我对HAProxy相当新,所以在这里寻找一个小方向。这里是问题的日志和配置。我试图强制使用特定的目标端口来使用特定的后端,但它无法正常工作。

Dec 18 18:49:34 localhost HAPLB[8405]: x.x.x.x:64725 [18/Dec/2014:18:49:27.157] 890_imappop_25 890_imappop_25-smtp/<NOSRV> -1/-1/7084 187 PR 225/35/35/0/3 0/0


backend 890_imappop_25-smtp
    balance roundrobin
    option redispatch
    stick-table type ip size 60k peers mypeers

    server filter1-mail 192.168.115.38:25 check
    server filter2-mail 192.168.115.39:25 check

listen 890_imappop_25
    bind 192.168.115.100:25
    mode tcp
    balance roundrobin
    option redispatch
    option tcplog
    log 127.0.0.1 local0 debug
    stick-table type ip size 60k peers mypeers

    acl smtp_25 dst_port 25
    acl smtp_225 dst_port 225
    acl smtp_587 dst_port 587

    use_backend 890_imappop_25-smtp if smtp_25
    use_backend 890_imappop_225-smtp if smtp_225
    use_backend 890_imappop_587-smtp if smtp_587

    server imappop1-mail 192.168.115.42:25 check
    server imappop2-mail 192.168.115.43:25 check

1 个答案:

答案 0 :(得分:1)

修复是将mode tcp添加到后端部分,因此在这种情况下它默认为HTTP,显然SMTP并不知道如何与之交谈。无法相信我忘记了。

backend 890_imappop_25-smtp
    balance roundrobin
    mode tcp
    option redispatch
    stick-table type ip size 60k peers mypeers

    server filter1-mail 192.168.115.38:25 check
    server filter2-mail 192.168.115.39:25 check