- See also
- Context path-based reverse proxy server example
- Configration directives used:
- global
- defaults
- frontend
- backend
- Configration directives used:
global
log local0 info
pidfile /var/run/haproxy.pid
maxconn 1000
user root
group root
defaults
mode http
log global
log-format "[%Tl] client=%ci, frontend=%fi:%fp, backend=%b, path=%HU, method=%HM, status=%ST"
balance roundrobin
option httpchk GET /
option dontlognull
option http-server-close
option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout queue 1m
timeout client 1m
timeout server 1m
timeout http-request 5s
timeout http-keep-alive 5s
timeout connect 5s
timeout check 5s
frontend stats # Enable the HAProxy stats page.
bind *:9000
stats enable
stats uri /
stats refresh 5s
frontend http # Redirect HTTP to HTTPS.
bind *:80
http-request redirect scheme https code 301 if !{ ssl_fc }
frontend https
bind *:443 ssl crt /usr/local/etc/haproxy/cert.pem
# Determine which backend to use based on path.
acl acl_pihole path_beg /admin /pihole
acl acl_heimdall path_beg /css /js /img /favicon /items /users /apple-icon /ms-icon /tags /settings
use_backend pihole if acl_pihole
use_backend heimdall if acl_heimdall
default_backend heimdall
# --------------------------------------------------------
backend pihole
server s_pihole 10.0.0.15:80 check
backend heimdall
http-request replace-path /heimdall/?(.*) /\1
server s_heimdall 10.0.0.10:443 check ssl verify none
- Subdomain-based reverse proxy server example
acl acl_home_assistant hdr_dom(host) -i homeassistant.domain.example.com
acl acl_pihole hdr_dom(host) -i pihole.domain.exmaple.com
use_backend home_assistant if acl_home_assistant
use_backend pihole if acl_pihole