1
我有一個haproxy集羣,有兩個前端用於http和https以及許多使用domain2backend映射選擇的後端。HAProxy在後端不工作的重定向方案
一些後端只能通過HTTPS訪問。
我試圖在後端使用redirect scheme https code 301 if !{ ssl_fc }
,但haproxy似乎忽略了它。我甚至試圖簡單地重定向(沒有任何條件),但haproxy忽略後端部分中的重定向。
配置摘錄:
global
maxconn 1024
debug
log localhost local0 debug
tune.ssl.default-dh-param 2048
defaults
balance roundrobin
maxconn 32
log global
monitor-uri /haproxy_test
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
frontend http-in
bind *:8080
mode http
option httplog
option forwardfor
use_backend %[req.hdr(host),lower,map_dom(./etc/domain2backend.map)]
frontend https-in
bind *:4443 ssl crt ./etc/ssl
mode http
option httplog
option forwardfor
http-request add-header X-Proto https if { ssl_fc }
use_backend %[req.hdr(host),lower,map_dom(./etc/domain2backend.map)]
backend app1_www
redirect scheme https if !{ ssl_fc }
server localhost:3000 127.0.0.1:3000 check
backend app2_www
redirect scheme https
server localhost:3000 127.0.0.1:3000 check
無論app1_www也不app2_www重定向工作。
我使用HA-代理1.7.3版2017年2月28日