I tried to receive request and want to redirect it to other host using dns name and exposed with https protocol. For example, my server is I want haproxy redirect this to https://partner.com/partnerA/getUser (same path as the source). I also want to filter by path for another redirect destination such as will redirected by HAProxy to https://subdomainb.differentpartner.com/partnerB/getMarketShare(notice the path also follow the same rule, but based on path it will give different host name.

I tried below haproxy.cfg

        log /dev/log    local0
        log /dev/log    local1 notice
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin
        stats timeout 30s
        user haproxy
        group haproxy

        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000

# main frontend which proxys to the backends
frontend  main
    bind *:10101
    acl url_partnerA       path_beg -i /partnerA
    acl url_partnerB       path_beg -i /partnerB
    http-request redirect scheme https if url_partnerA
    http-request redirect scheme https if url_partnerB
    http-request redirect prefix https://partnerA.com if url_partnerA
    http-request redirect prefix https://subdomainb.differentpartner.com/ if url_partnerA
    default_backend             app

# round robin balancing between the various backends
backend app
    balance     roundrobin
   # server  app1 check

But everytime I access (I use http) POST, the log from haproxy -f haproxy10101.cfg -d will give me this

00000000:main.accept(0005)=0009 from [] ALPN=<none>
00000000:main.clireq[0009:ffffffff]: POST /partnerA/getUser HTTP/1.1
00000000:main.clihdr[0009:ffffffff]: Host:
00000000:main.clihdr[0009:ffffffff]: User-Agent: curl/7.47.0
00000000:main.clihdr[0009:ffffffff]: Accept: */*
00000000:main.clihdr[0009:ffffffff]: Authorization: Basic dGNhc2g6RzBqM2tmMHJsMWYzIQ==
00000000:main.clihdr[0009:ffffffff]: Content-Type: application/json
00000000:main.clihdr[0009:ffffffff]: Postman-Token: 45a236c-740a-4859-a13a-1c45195a99f2
00000000:main.clihdr[0009:ffffffff]: cache-control: no-cache
00000000:main.clihdr[0009:ffffffff]: Content-Length: 218

Anything I miss to make it work? Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.