This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| deb13:haconfig [2026/09/15 08:23] – Bernard Condrau | deb13:haconfig [2026/10/29 17:30] (current) – Bernard Condrau | ||
|---|---|---|---|
| Line 7: | Line 7: | ||
| # | # | ||
| # Features: | # Features: | ||
| - | # acme integration, | + | # HTTP/1, HTTP/2, HTTP/ |
| # | # | ||
| # Notes: | # Notes: | ||
| # # = comment, ## = acme integration, | # # = comment, ## = acme integration, | ||
| # | # | ||
| - | # | + | # |
| # | # | ||
| # 0. Settings | # 0. Settings | ||
| Line 43: | Line 43: | ||
| log-format " | log-format " | ||
| timeout connect 5s | timeout connect 5s | ||
| - | timeout client | + | timeout client |
| - | timeout server | + | timeout server |
| # 1. Public Interface (SNI Router) | # 1. Public Interface (SNI Router) | ||
| + | # Receives traffic through TCP (HTTP) | ||
| frontend public_inbound_http | frontend public_inbound_http | ||
| bind *:80 | bind *:80 | ||
| Line 60: | Line 61: | ||
| http-request redirect scheme https code 301 unless { ssl_fc } | http-request redirect scheme https code 301 unless { ssl_fc } | ||
| + | # Receives traffic through TCP (HTTP/1, HTTP/2) | ||
| frontend public_inbound_https | frontend public_inbound_https | ||
| bind :443 | bind :443 | ||
| Line 74: | Line 76: | ||
| # Remove once all hosts are terminated here | # Remove once all hosts are terminated here | ||
| acl terminate_ssl req.ssl_sni -i bak.condrau.com | acl terminate_ssl req.ssl_sni -i bak.condrau.com | ||
| + | acl terminate_mail req.ssl_sni -i mail.condrau.com | ||
| # Route conditionally based on SNI | # Route conditionally based on SNI | ||
| use_backend http_dispatcher if terminate_ssl | use_backend http_dispatcher if terminate_ssl | ||
| + | use_backend webmail_server if terminate_mail | ||
| default_backend passthrough_server | default_backend passthrough_server | ||
| + | |||
| + | # Receives traffic through UDP (HTTP/3), decrypts SSL, and processes HTTP rules | ||
| + | # HTTP/3 cannot be routed to apache web server without decrypting SSL first | ||
| + | frontend public_inbound_https3 | ||
| + | |||
| + | # pass certs directory path so all pem files will be loaded | ||
| + | # uncomment the following line once all hosts are SSL terminated here | ||
| + | # bind :443 | ||
| + | bind quic4@:443 ssl crt / | ||
| + | mode http | ||
| + | |||
| + | # Handle Letsencrypt requests | ||
| + | ## | ||
| + | |||
| + | # Deny traffic based on origin (host aware) | ||
| + | acl trusted_ip src -f / | ||
| + | acl whitelist_ip src, | ||
| + | acl backuppc hdr(host) -i bak.condrau.com | ||
| + | http-request deny if backuppc !trusted_ip !whitelist_ip | ||
| + | |||
| + | # Let clients know we support HTTP/3 | ||
| + | http-response set-header Alt-Svc ' | ||
| + | |||
| + | # Inject headers so backend servers know the original request was HTTPS | ||
| + | http-request set-header X-Forwarded-Proto https | ||
| + | http-request set-header X-Forwarded-Port 443 | ||
| + | http-request set-header X-Forwarded-For %[src] | ||
| + | |||
| + | # Route traffic based on HTTP host headers | ||
| + | use_backend backuppc_server if backuppc | ||
| + | default_backend http_server | ||
| # 2. Transparent passthrough for encrypted TLS domains | # 2. Transparent passthrough for encrypted TLS domains | ||
| Line 84: | Line 119: | ||
| # downstream server handling its own TLS certificates (Calypso) | # downstream server handling its own TLS certificates (Calypso) | ||
| - | server calypso 192.168.3.18:443 check | + | server calypso 192.168.3.90:443 check |
| + | |||
| + | backend webmail_server | ||
| + | mode tcp | ||
| + | |||
| + | # downstream (synology mail) server handling its own TLS certificates (Merkur) | ||
| + | server merkur 192.168.3.90: | ||
| # 3. Intermediary loopback backend | # 3. Intermediary loopback backend | ||
| Line 92: | Line 133: | ||
| server loopback 127.0.0.1: | server loopback 127.0.0.1: | ||
| - | # 4. Layer 7 http frontend | + | # 4. Layer 7 http frontend |
| # Receives traffic from the loopback, decrypts SSL, and processes HTTP rules | # Receives traffic from the loopback, decrypts SSL, and processes HTTP rules | ||
| frontend internal_inbound_http | frontend internal_inbound_http | ||
| Line 124: | Line 165: | ||
| backend backuppc_server | backend backuppc_server | ||
| mode http | mode http | ||
| + | http-reuse safe | ||
| cookie SERVERID insert indirect nocache | cookie SERVERID insert indirect nocache | ||
| server epione 192.168.1.50: | server epione 192.168.1.50: | ||
| Line 129: | Line 171: | ||
| backend http_server | backend http_server | ||
| mode http | mode http | ||
| + | http-reuse aggressive | ||
| cookie SERVERID insert indirect nocache | cookie SERVERID insert indirect nocache | ||
| - | server serenity 192.168.3.100: | + | server serenity 192.168.3.100: |
| # 6. stick table that stores IPv4 addresses | # 6. stick table that stores IPv4 addresses | ||
| Line 159: | Line 202: | ||
| * Remove IP address from whitelist stick table:< | * Remove IP address from whitelist stick table:< | ||
| * Show content of whitelist stick table:< | * Show content of whitelist stick table:< | ||
| - | * To add an IP address | + | * To add an IP address |
| - | IP=$(dig +short host.duckdns.org) | + | echo "clear table stick_table_whitelist" |
| - | ERROR=$? | + | |
| - | # | + | |
| - | # do not update if DIG timed out | + | |
| - | if [ $ERROR -eq 0 ]; then | + | |
| - | # update HAProxy stick table | + | |
| - | | + | |
| - | fi | + | |
| </ | </ | ||
| - | | + | * To make this work you need to add < |
| - | | + | < |
| - | < | + | * Call the script |
| - | * To remove an IP address | + | # bco, 2026-09-20 |
| + | # update my current IP address in HAProxy stick table | ||
| # | # | ||
| - | # update HAProxy stick table | + | IP=$(curl -s https://api.ipify.org) |
| - | echo "clear table stick_table_whitelist" | + | |
| - | </ | + | # Regex pattern matching 0-255 for individual octets |
| - | * This way you can add your computer to the trusted IP list (whitelist) no matter what is the current IP address, provided that you set up a dynamic domain name which you can update with your [[#powershell|Powerhell]] script below. | + | octet=' |
| + | pattern=" | ||
| - | ===== Powershell ===== | + | if [[ $IP =~ $pattern ]]; then |
| - | * Create the following Powershell script and use it with a shortcut to '' | + | ssh -p 50322 huahin.condrau.com "echo \"set table stick_table_whitelist key $IP\" | sudo /usr/bin/socat / |
| - | # This is an example Powershell file for DuckDNS updater, see https://www.duckdns.org | + | else |
| - | param($domain) | + | |
| - | $duckdomain = if (!$domain) { " | + | sleep 5 |
| - | $addr = curl.exe -s "https:// | + | exit 1 |
| - | curl.exe -k " | + | fi |
| + | exit 0 | ||
| </ | </ | ||
| + | * Put a shortcut on the Windows Desktop for easy access:< | ||
| + | * This way you can add your computer to the trusted IP list (whitelist) no matter what is the current IP address. | ||