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:47] – Bernard Condrau | deb13:haconfig [2026/10/29 17:30] (current) – Bernard Condrau | ||
|---|---|---|---|
| Line 12: | Line 12: | ||
| # # = 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 | ||
| - | # 2. Transparent passthrough for encrypted TLS domains | + | # Receives |
| - | backend passthrough_server | + | # HTTP/3 cannot be routed to apache web server without decrypting SSL first |
| - | mode tcp | + | frontend |
| - | + | ||
| - | # downstream server handling its own TLS certificates (Calypso) | + | |
| - | server calypso 192.168.3.18: | + | |
| - | + | ||
| - | # 3. Intermediary loopback backend | + | |
| - | # This forwards | + | |
| - | backend http_dispatcher | + | |
| - | mode tcp | + | |
| - | server loopback 127.0.0.1: | + | |
| - | + | ||
| - | # 4. Layer 7 http frontend | + | |
| - | # Receives traffic from the loopback, decrypts SSL, and processes HTTP rules | + | |
| - | frontend | + | |
| # pass certs directory path so all pem files will be loaded | # pass certs directory path so all pem files will be loaded | ||
| - | bind 127.0.0.1:8443 ssl crt / | + | |
| + | # bind :443 | ||
| + | bind quic4@: | ||
| mode http | mode http | ||
| Line 121: | Line 114: | ||
| default_backend http_server | default_backend http_server | ||
| - | # 5. Layer 7 http frontend (HTTP/3) | + | # 2. Transparent passthrough for encrypted TLS domains |
| - | # Receives traffic | + | backend passthrough_server |
| - | # HTTP/3 cannot be routed to apache web server without decrypting SSL first | + | mode tcp |
| - | frontend | + | |
| + | # downstream server handling its own TLS certificates (Calypso) | ||
| + | server calypso 192.168.3.90: | ||
| + | |||
| + | 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 | ||
| + | # This forwards traffic to the Layer 7 (HTTP) processing frontend | ||
| + | backend http_dispatcher | ||
| + | mode tcp | ||
| + | server loopback 127.0.0.1: | ||
| + | |||
| + | # 4. Layer 7 http frontend (HTTP/1, HTTP/2) | ||
| + | # Receives traffic | ||
| + | frontend | ||
| # pass certs directory path so all pem files will be loaded | # pass certs directory path so all pem files will be loaded | ||
| - | bind quic4@:443 ssl crt / | + | bind 127.0.0.1:8443 ssl crt / |
| mode http | mode http | ||
| Line 151: | Line 162: | ||
| default_backend http_server | default_backend http_server | ||
| - | # 6. HTTP backends | + | # 5. HTTP backends |
| 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 159: | 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: |
| - | # 7. stick table that stores IPv4 addresses | + | # 6. stick table that stores IPv4 addresses |
| backend stick_table_whitelist | backend stick_table_whitelist | ||
| mode http | mode http | ||
| Line 189: | 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. | ||