Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm setting up haproxy to use multiple backend servers but want one of them to handle particular requests:

backend bagend
        mode http
        balance roundrobin
        option httpchk GET / HTTP/1.1\r\nHost:\ www.example.com
        use-server app1_00 if { path_beg /frodo }
        use-server app1_01 if { path_beg /frodo }
        use-server app1_02 if { path_beg /frodo }
        use-server app1_03 if { path_beg /frodo }
        server  app1_00 10.0.0.1:9100 check
        server  app1_01 10.0.0.1:9101 check
        server  app1_02 10.0.0.1:9102 check
        server  app1_03 10.0.0.1:9103 check
        server  app2_00 10.0.0.2:9100 check
        server  app2_01 10.0.0.2:9101 check
        server  app2_02 10.0.0.2:9102 check
        server  app2_03 10.0.0.2:9103 check

Will my use-server commands balance across all 4 backends on app1? Or do I need to do this a different way? It looks as though everything is going to app1_00.

share|improve this question
add comment

1 Answer

What you want to do is have an acl in the frontend send the request to a different backend based on the URL.

frontend shire
    bind *:80
    mode http
    acl path-frodo path_beg /frodo
    use backend longbottom if path-frodo
    default_backend bagend

backend longbottom
    mode http
    balance roundrobin
    option httpchk GET / HTTP/1.1\r\nHost:\ www.example.com
    server  app1_00 10.0.0.1:9100 check
    server  app1_01 10.0.0.1:9101 check
    server  app1_02 10.0.0.1:9102 check
    server  app1_03 10.0.0.1:9103 check

backend bagend
    mode http
    balance roundrobin
    option httpchk GET / HTTP/1.1\r\nHost:\ www.example.com
    server  app1_00 10.0.0.1:9100 check
    server  app1_01 10.0.0.1:9101 check
    server  app1_02 10.0.0.1:9102 check
    server  app1_03 10.0.0.1:9103 check
    server  app2_00 10.0.0.2:9100 check
    server  app2_01 10.0.0.2:9101 check
    server  app2_02 10.0.0.2:9102 check
    server  app2_03 10.0.0.2:9103 check

All request beginning with /frodo will hit only app1_00, app1_01, app1_02 and app1_03. All other requests will hit everything.

share|improve this answer
    
I thought of this, but I loathe to do so there's a lot of backend config that I'd just have to copy and paste around. It'll do, but it seems… not ideal. –  MikeyB Feb 4 '13 at 23:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.