How do I setup acls to split a server by directory


#1

I still have a lot to learn with HA Proxy. I know it’s done through acls but I’m not sure how to do it properly. Can someone show me the right way to make all of the server urls except one go to the default server and the /other url to another server? Thanks in advance!

global
    log         127.0.0.1 local2 debug
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    stats socket /var/lib/haproxy/stats
    tune.ssl.default-dh-param 1024

defaults
    mode                    http
    option                  httplog
    log                     global
    option                  dontlognull
    option                  http-server-close
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

frontend frontend-http
    bind 1.2.3.4:80
    default_backend backend-http

backend backend-http
    option forwardfor
    server web-1 www.website1.com:80 check

frontend frontend-https
    bind 1.2.3.4:443 ssl crt /etc/haproxy/ssl/default.pem crt /etc/haproxy/ssl
    default_backend backend-https

backend backend-https
    option forwardfor
    server web-1 www.website1.com:443 check ssl verify none

#2

Hi

frontend frontend-http
    bind 1.2.3.4:80 
    acl foo path_beg -i /foo
    use_backend backend-foo if foo 
    default_backend backend-http

backend backend-foo
    option forwardfor
    server web-2 www.website1.com:80 check

if url begins with /foo it will use backend-foo , others will go to default backend


#3

Awesome, that was perfect. Thanks!