I hope you are following the below guide. Now suppose you want to route domain name to open specific backend that have your configuration file.
How to route domain name
Find
frontend https
mode http
bind *:443 ssl crt /etc/letsencrypt/live/web.bullten.work/web.bullten.work.pem crt /etc/letsencrypt/live/haproxy1.bullten.work/haproxy1.bullten.work.pem alpn h2,http/1.1
option forwardfor
http-request track-sc0 src table per_ip_rates
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 100 }
acl from_cf src -f /etc/haproxy/cloudflare_ips.lst
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
default_backend app-main
Now at the end add
acl host_bacon hdr(host) -i haproxy1.bullten.work
use_backend bacon_cluster if host_bacon
So it will look like. Replace haproxy1.bullten.work with your domain name
frontend https
mode http
bind *:443 ssl crt /etc/letsencrypt/live/web.bullten.work/web.bullten.work.pem alpn h2,http/1.1
option forwardfor
http-request track-sc0 src table per_ip_rates
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 100 }
acl from_cf src -f /etc/haproxy/cloudflare_ips.lst
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
acl host_bacon hdr(host) -i haproxy1.bullten.work
use_backend bacon_cluster if host_bacon
default_backend app-main
Now create a backend bacon_cluster
backend bacon_cluster
mode http
balance roundrobin #Balance algorithm
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost #Check the server application is up and healty - 200 status code
timeout queue 10s
server nginx1 192.168.1.1:443 check ssl verify none weight 3 #Nginx1
This will tell to haproxy to point to bacon_cluster when domain entered is haproxy1.bullten.work
Now just setup SSL. Replace haproxy1.bullten.work with your domain name.
frontend https
mode http
bind *:443 ssl crt /etc/letsencrypt/live/web.bullten.work/web.bullten.work.pem crt /etc/letsencrypt/live/haproxy1.bullten.work/haproxy1.bullten.work.pem alpn h2,http/1.1
option forwardfor
http-request track-sc0 src table per_ip_rates
http-request deny deny_status 429 if { sc_http_req_rate(0) gt 100 }
acl from_cf src -f /etc/haproxy/cloudflare_ips.lst
http-request set-src req.hdr(CF-Connecting-IP) if from_cf
acl host_bacon hdr(host) -i haproxy1.bullten.work
use_backend bacon_cluster if host_bacon
default_backend app-main