2023年8月10日 星期四

HAProxy Reverse Proxy with SSL

憑證掛在 Reverse Proxy, 內部走 HTTP

frontend http-in
mode http
bind *:80
bind *:443 ssl crt /etc/haproxy/pank.org-crt-chain-key.pem
use_backend %[req.hdr(Host),lower]

backend test1.pank.org
balance first
mode http
option forwardfor except 127.0.0.0/8
server web-1 192.168.0.27:80

backend test2.pank.org
balance first
mode http
option forwardfor except 127.0.0.0/8
server web-2 192.168.0.42:80

test1.pank.org 及 test2.pank.org 使用同一個 wildcard 憑證,
crt 是 crt+chain+key 放同一個檔
若兩個站的憑證不同,可以用 crt-list 指定多個憑證
例: bind *:443 ssl crt-list /etc/haproxy/crt-list.txt
crt-list.txt 的內容
/etc/haproxy/domain1.com-crt-chain-key.pem
/etc/haproxy/domain2.com-crt-chain-key.pem
有設定 option forwardfor 會帶 X-Forwarded-For 到 backend server

沒有留言:

Certificate lifetime reduce to 47 days after 2029-03-15

在 2020年九月,憑證效期縮短為 398 天 爾後最新標準是 47 天,原因一樣是資安考量,分三個階段逐步調整 執行時間表 2026-03-15 縮短成 200 天 2027-03-15 縮短成 100 天 2029-03-15 縮短成 47 天 圖片來源 Sectigo r...