Score:1

HAProxy goes to the same website even though they have different sub-domains

de flag

I have an issue with HAProxy where it goes to the same website even though they have different sub-domains.

For example, I go to foo.domain.com then on another tab I go to bar.domain.com and another tab for baz.domain.com, all three loads the foo.domain.com website and when I hard refresh the other sites it goes properly to the proper website then it happens again making the new website the face of all domains unless I keep refreshing the websites.

I have the following configuration:

defaults
        log     global
        mode    http
        option  tcplog
        option  dontlognull
        retries 3
        option  redispatch
        maxconn 30000
        timeout connect 10s
        timeout client 60s
        timeout server 60s

frontend http_in
        mode http
        option httplog
        bind *:80
        option forwardfor
 
        acl host_foo hdr(host) -i foo.domain.com 
        acl host_bar hdr(host) -i bar.domain.com
        acl host_baz hdr(host) -i baz.domain.com

        use_backend http_foo if host_foo
        use_backend http_bar if host_bar
        use_backend http_baz if host_baz

backend http_foo
        mode http
        option httplog
        option forwardfor
        server foo foo:80

backend http_bar
        mode http
        option httplog
        option forwardfor
        server bar bar:80
    
backend http_baz
        mode http
        option httplog
        option forwardfor
        server baz baz:80

frontend https_in
        mode tcp
        option tcplog
        bind *:443
        acl tls req.ssl_hello_type 1
        tcp-request inspect-delay 5s
        tcp-request content accept if tls

        acl host_foo req.ssl_sni -i foo.domain.com
        acl host_bar req.ssl_sni -i bar.domain.com
        acl host_baz req.ssl_sni -i baz.domain.com
        
        use_backend https_foo if host_foo
        use_backend https_bar if host_bar
        use_backend https_baz if host_baz

backend https_foo
        mode tcp
        option tcplog
        option ssl-hello-chk
        server foo foo:443

backend https_bar
        mode tcp
        option tcplog
        option ssl-hello-chk
        server bar bar:443

backend https_baz
        mode tcp
        option tcplog
        option ssl-hello-chk
        server baz baz:443

I'm using HAProxy version 2.4.12. Is there anything to do to prevent this from happening?

Score:0
hr flag

You need to pass the host header, something like within HTTP mode:

backend https_baz
    mode http
    option ssl-hello-chk
    reqirep ^Host: Host:\ baz.domain.com
    server baz baz:443
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.