HAProxy ACL for Load Balancing on URL Request

Until today I was using the basic HAProxy settings, Today i found a task about selection of backend server basis of url request. While working on this task, I learned about HAProxy ACLs.

Task: I have wordpress installed as http://domainname.com/blog . This domain is running from 2 backend server and balanced by HAProxy, The task is to redirect all /blog requrest to only single server.

Network Scenario for this setup

  • HAProxy Server:
  • WEB1 :
  • WEB2 :
  • Domain: tecadmin.net

The below example includes ACL for url_beg. url_beg matches the string used in url submitted. Using the url all requests starting with /blog ( tecadmin.net/blog ) will redirect to WEB2 ( ) Server. All other requests will redirect to one of two server ( WEB1, WEB2 ), depending on load balancing algorithm used.

Here is a quick example of uses url_beg ACL:

    log local0 notice
    maxconn 50000
    log global
    mode http
    option httplog
    option dontlognull
    contimeout 120000
    clitimeout 120000
    srvtimeout 120000
    option forwardfor
    option http-server-close

# Configuration for HTTP site
frontend http-in
    acl is_blog url_beg  /blog
    use_backend tecadmin_blog if is_blog
    default_backend tecadmin_website

backend tecadmin_blog
    mode http
    balance roundrobin  # Load Balancing algorithm
    option httpchk
    option forwardfor
    server WEB2 weight 1 maxconn 512 check

backend tecadmin_website
    mode http
    balance roundrobin  # Load Balancing algorithm
    option httpchk
    option forwardfor
    server WEB1 weight 1 maxconn 512 check
    server WEB2 weight 1 maxconn 512 check

I hope this tutorial will help you to configure some basic ACL with haproxy .Regarding full configuration settings available for the ACL are listed in the haproxy configuration doc,


Founder of TecAdmin.net. I love to work with Linux and other open source application. Also I like to share knowledge with my friends and other Linux users. Follow me on Twitter, Add me on Google+ or Like Facebook page.

1 Comment

  1. Very informative post…. I also never used ACl with haproxy, thanks

Leave a Reply


Support us!

If you like this site please help and make click on any of these buttons!