Search code examples
haproxy

HAProxy and passing an ID string


I've got a HAProxy issue - I've got URLS for site.com/index.php?ID=Blah that I need to pass on to a back end server.

I'm using an ACL with hdr_sub(host) -i site.com to do this but I keep getting a 503 so I don't think the acl is working.

I was expecting haproxy to pass the full string on to the back end when the host met the URL "site.com" but I just get a 503.

how do I ensure the ACL can pick up the various parameters and send the full URL down to the back end server?

Cheers.


Solution

  • If you are getting a 503 that could mean that no backend is mapped for your request. In your frontend section you need to tell haproxy which backend to use for your request. So using the ACL you mentioned:

    frontend default
    bind :80
    
    acl acl_site.com hdr_sub(host) -i site.com
    use_backend be_site.com if acl_site.com
    
    use_backend default
    

    Then you need to define the backend section (the ip's are only examples):

    backend be_site.com
       mode http
       server s1 192.168.1.25:80
       server s2 192.168.1.26:80
    
    backend default
        http-request deny deny_status 404