HAproxy www with multiple sites?
-
Hi,
I was wondering if someone could shed some light on the issue im having,
Currently i have HAproxy working fine with multiple sub domains, but im having an issue with the www to redirect to multiple domains.
ex: www.mydomain.com i can redirect no issue
but with i want to also use www.domain2.com it would go to www.mydomain.comThis is the config i have right now
# Automaticaly generated, dont edit manually. # Generated on: 2021-08-02 20:18 global maxconn 500 stats socket /tmp/haproxy.socket level admin expose-fd listeners gid 80 nbproc 1 nbthread 1 hard-stop-after 15m chroot /tmp/haproxy_chroot daemon tune.ssl.default-dh-param 2048 server-state-file /tmp/haproxy_server_state listen HAProxyLocalStats bind 127.0.0.1:2200 name localstats mode http stats enable stats admin if TRUE stats show-legends stats uri /haproxy/haproxy_stats.php?haproxystats=1 timeout client 5000 timeout connect 5000 timeout server 5000 frontend SharedFrontend-merged bind 200.xx.xx.xx:443 name 200.xx.xx.xx:443 mode tcp log global timeout client 30000 tcp-request connection set-src str(192.168.3.254) if { src 192.168.3.0/24 } tcp-request inspect-delay 5s acl cloud req.ssl_sni -i cloud.domain.com acl web req.ssl_sni -i domain.com acl inventory req.ssl_sni -i inventory.domain.com acl ng req.ssl_sni -i ng.domain.com acl gitlab req.ssl_sni -i gitlab.domain.com acl remote req.ssl_sni -i remote.domain.com acl monitor req.ssl_sni -i monitor.domain.com acl mail req.ssl_sni -i mail.domain.com.co acl crm req.ssl_sni -i crm.domain.com acl chat req.ssl_sni -i chat.domain.com acl office req.ssl_sni -i onlyoffice.domain.com acl task req.ssl_sni -i task.domain.com acl sistema req.ssl_sni -i sistema.domain.com acl ids req.ssl_sni -i ids.domain.com acl capacitaciones req.ssl_sni -i capacitaciones.domain.com acl wiki req.ssl_sni -i wiki.domain.com acl deep req.ssl_sni -i domain2.com acl contable req.ssl_sni -i contable.domain.com acl logistica req.ssl_sni -i domain3.com.co tcp-request content accept if { req.ssl_hello_type 1 } use_backend Backend2_ipv4 if cloud use_backend Backend1_ipv4 if web use_backend Backend9_ipv4 if inventory use_backend Backend10_ipv4 if ng use_backend Backend13_ipvANY if gitlab use_backend Backend14_ipv4 if remote use_backend Backend17_ipvANY if monitor use_backend Backend18_ipv4 if mail use_backend Backend7_ipvANY if crm use_backend Backend19_ipv4 if chat use_backend Backend20_ipv4 if office use_backend Backend21_ipv4 if task use_backend Backend22_ipv4 if sistema use_backend Backend24_ipv4 if ids use_backend Backend25_ipv4 if capacitaciones use_backend Backend26_ipv4 if wiki use_backend Backend27_ipv4 if deep use_backend Backend28_ipv4 if contable use_backend Backend29_ipv4 if logistica frontend HTTPTOHTTPS bind 200.xx.xx.xx:80 name 200.xx.xx.xx:80 mode http log global option http-keep-alive timeout client 30000 tcp-request connection set-src str(192.168.3.254) if { src 192.168.3.0/24 } acl cloud var(txn.txnhost) -m str -i cloud.domain.com acl web var(txn.txnhost) -m str -i domain.com acl inventory var(txn.txnhost) -m str -i inventory.domain.com acl ng var(txn.txnhost) -m str -i ng.domain.com acl gitlab var(txn.txnhost) -m str -i gitlab.domain.com acl remote var(txn.txnhost) -m str -i remote.domain.com acl contable var(txn.txnhost) -m str -i contable.domain.com acl home var(txn.txnhost) -m str -i home.domain.com acl monitor var(txn.txnhost) -m str -i monitor.domain.com acl mail var(txn.txnhost) -m str -i mail.domain.com.co acl crm var(txn.txnhost) -m str -i crm.domain.com acl chat var(txn.txnhost) -m str -i chat.domain.com acl office var(txn.txnhost) -m str -i onlyoffice.domain.com acl task var(txn.txnhost) -m str -i task.domain.com acl sistema var(txn.txnhost) -m str -i sistema.domain.com acl ids var(txn.txnhost) -m str -i ids.domain.com acl capacitaciones var(txn.txnhost) -m str -i capacitaciones.domain.com acl wiki var(txn.txnhost) -m str -i wiki.domain.com acl deep var(txn.txnhost) -m str -i domain2.com acl logistica var(txn.txnhost) -m str -i domain3.com.co http-request set-var(txn.txnhost) hdr(host) http-request redirect scheme https if cloud http-request redirect scheme https if web http-request redirect prefix https://domain2.com if deep http-request redirect scheme https if mail http-request redirect scheme https if inventory http-request redirect scheme https if ng http-request redirect scheme https if gitlab http-request redirect scheme https if remote http-request redirect scheme https if contable http-request redirect scheme https if home http-request redirect scheme https if monitor http-request redirect scheme https if crm http-request redirect scheme https if chat http-request redirect scheme https if office http-request redirect scheme https if task http-request redirect scheme https if sistema http-request redirect scheme https if contable http-request redirect scheme https if ids http-request redirect scheme https if capacitaciones http-request redirect scheme https if wiki http-request redirect scheme https if deep http-request redirect scheme https if contable http-request redirect scheme https if logistica http-request redirect prefix https://domain.com if web backend Backend2_ipv4 mode tcp id 10103 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server cloud 192.168.3.244:443 id 10104 check inter 1000 backend Backend1_ipv4 mode tcp id 10101 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server website 192.168.3.201:443 id 10102 check inter 1000 backend Backend9_ipv4 mode tcp id 10100 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server inventory 192.168.3.223:443 id 10104 check inter 1000 backend Backend10_ipv4 mode tcp id 10117 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server ng 192.168.3.222:443 id 10104 check inter 1000 backend Backend13_ipvANY mode tcp id 120 log global timeout connect 30000 timeout server 30000 retries 3 server gitlab 192.168.3.121:443 id 104 check inter 1000 backend Backend14_ipv4 mode tcp id 10121 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server remote 192.168.3.245:443 id 10104 check inter 1000 backend Backend17_ipvANY mode tcp id 124 log global timeout connect 30000 timeout server 30000 retries 3 server monitor 192.168.3.132:443 id 104 check inter 1000 backend Backend18_ipv4 mode tcp id 10105 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server mail 192.168.3.140:443 id 10104 check inter 1000 backend Backend7_ipvANY mode tcp id 113 log global timeout connect 30000 timeout server 30000 retries 3 server crm 192.168.3.155:443 id 114 check inter 1000 backend Backend19_ipv4 mode tcp id 10106 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server chat 192.168.3.201:443 id 10104 check inter 1000 backend Backend20_ipv4 mode tcp id 10107 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server office 192.168.3.253:443 id 10104 check inter 1000 backend Backend21_ipv4 mode tcp id 10108 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server task 192.168.3.248:443 id 10104 check inter 1000 backend Backend22_ipv4 mode tcp id 10110 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server sistema 192.168.3.169:443 id 10104 check inter 1000 backend Backend24_ipv4 mode tcp id 10112 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server ids 192.168.3.157:443 id 10104 check inter 1000 backend Backend25_ipv4 mode tcp id 10115 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server capacitaciones 192.168.3.192:443 id 10104 check inter 1000 backend Backend26_ipv4 mode tcp id 10109 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server wiki 192.168.3.190:443 id 10104 check inter 1000 backend Backend27_ipv4 mode tcp id 10116 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server deep 192.168.3.193:443 id 10104 check inter 1000 backend Backend28_ipv4 mode tcp id 10111 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server contable 192.168.3.180:443 id 10104 check inter 1000 backend Backend29_ipv4 mode tcp id 10118 log global timeout connect 30000 timeout server 30000 retries 3 source ipv4@ usesrc clientip server logistica 192.168.3.156:443 id 10104 check inter 1000
-
edit: fixed it had to add another access control list with www pointing to the acl hope this helps someone else
Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.