tarun mittal
tarun mittal

Reputation: 629

Single haproxy instance running on http as well as tcp mode

I have two web applications running on a server inside two separate docker containers, one of them is running on play framework server (java), while other is running on nginx (php). I am doing ssl termination in http mode at haproxy for the play app. I want to handle the ssl termination for other app at nginx. Is it possible to configure haproxy in such a way, so that one front-end forwards the request in tcp mode, and another in http mode. Below is how my haproxy.cfg would look like.

frontend http-in
        mode http
        bind *:80
        redirect scheme https code 301 if !{ ssl_fc }


frontend https-in
#        bind *:80
        bind *:443 ssl crt /etc/ssl/certs/my_certificate_file.pem
        reqadd X-Forwarded-Proto:\ https
#        redirect scheme https code 301 if !{ ssl_fc }
        mode http
        option httpclose
        option forwardfor
        # Define hosts based on domain names
        acl host_test_ssh hdr(host) -i playapp.domain.com

        ## figure out backend to use based on domainname
        use_backend testssh if host_test_ssh

frontend http-in-other
        bind *:80
        mode tcp
        option tcplog
        redirect scheme https if !{ ssl_fc }

frontend https-in-estore
        bind *:443
        mode tcp
        option tcplog
        # Define hosts based on domain names
        acl host_test_ssh hdr(host) -i nginxapp.domain2.com

        ## figure out backend to use based on domainname
        use_backend other if host_test_ssh

Upvotes: 1

Views: 8679

Answers (1)

Gene Diaz
Gene Diaz

Reputation: 536

I have not tried this but based on the documentation of 1.5 it should work. http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4.2-mode

Upvotes: 0

Related Questions