Logan Best
Logan Best

Reputation: 501

Redirecting to backend based on port

I'm fairly new to HAProxy so just looking for a little direction here. Here's a log of the problem and the config for that as well. I'm trying to force specific destination ports to use a specific backend and it's not working.

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

Upvotes: 2

Views: 8113

Answers (1)

Logan Best
Logan Best

Reputation: 501

The fix was to add mode tcp to the backend section, so in this case it was defaulting to HTTP which obviously SMTP doesn't know how to talk to. Can't believe I forgot that.

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

Upvotes: 1

Related Questions