Below is the configuration, what I need is for all urls like
http//domain.tdl/ww/... 
to use back end 1 or 2 or default load balancer, 
and all other request to go to Apache, but I get an error:
[ALERT] 170/013846 (5151) : parsing [/etc/haproxy/haproxy.cfg:43] :
error detected while parsing switching rule.
at:
    use_backend bck1 if srv1_up srv1 and if has_ww_uri
    use_backend bck2 if srv2_up srv2 and if has_ww_uri
is there something I did wrong in my use of "and"?
I will use my IP address in place of 0.0.0.0
I also want to redirect www to root,
and have a status page,
thanks for any help.

# nano /etc/haproxy/haproxy.cfg
global
    log 127.0.0.1 local0 
    log 127.0.0.1 local1 notice
    maxconn 4096
    user haproxy
    group haproxy
    daemon
    stats socket    /tmp/haproxy     

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    option  http-server-close
    option  http-pretend-keepalive
    option  forwardfor
    option  originalto
    retries 3
    option  redispatch
    maxconn    2048
    contimeout 5000
    clitimeout 50000
    srvtimeout 50000
    option httpclose

frontend wt
    bind 0.0.0.0:80
    # option http-server-close  # HTTP keepalive without killing Apache
    redirect prefix http://domain.com code 301 if { hdr(host) -i
www.domain.com } 
    #
    acl has_ww_uri path_beg -i /ww  
    #
    acl srv1 url_sub wtd=wt1
    acl srv2 url_sub wtd=wt2
    acl srv1_up nbsrv(bck1) gt 0
    acl srv2_up nbsrv(bck2) gt 0
    use_backend bck1 if srv1_up srv1 and if has_ww_uri
    use_backend bck2 if srv2_up srv2 and if has_ww_uri
    use_backend bck_lb if has_ww_uri 
    default_backend apache

backend apache
    # option http-server-close # HTTP keepalive without killing Apache
    # set the maxconn parameter below to match Apache's MaxClients minus
one or two connections so that you can still directly connect to it.
    server srv 127.0.0.1:8080 maxconn 254
        
backend bck_lb
    balance roundrobin
    server srv1 0.0.0.0:8088 track bck1/srv1
    server srv2 0.0.0.0:8089 track bck2/srv2

backend bck1
    balance roundrobin
    server srv1 0.0.0.0:8088 check

backend bck2
    balance roundrobin
    server srv2 0.0.0.0:8089 check

# haproxy stat http://domain.tld:1936/haproxy?stats 
listen stats :1936                  
    mode http                       
    stats enable                    
    stats hide-version              
    stats realm Haproxy\ Statistics 
    stats uri /                     
    stats auth userName:Password
# EOF #

Reply via email to