Redirect 后端中的HAProxy重定向方案不工作
我有一个haproxy集群,有两个用于http和https的前端,还有许多使用domain2backend映射选择的后端 某些后端只能通过HTTPS访问 我尝试使用Redirect 后端中的HAProxy重定向方案不工作,redirect,haproxy,Redirect,Haproxy,我有一个haproxy集群,有两个用于http和https的前端,还有许多使用domain2backend映射选择的后端 某些后端只能通过HTTPS访问 我尝试使用重定向方案https code 301 if!{ssl_fc}在这些后端,但haproxy似乎忽略了它。我甚至试图简单地重定向(没有任何条件),但haproxy忽略了后端部分中的重定向 配置摘录: global maxconn 1024 debug log localhost local0 debug
重定向方案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 Proxy版本1.7.3 2017/02/28,多亏了位于的社区的帮助,我找到了解决方案: 有必要在后端指定
模式http
,以允许重定向工作
变量ssl_fc在后端可用,因此可以使用条件if!{ssl_fc}
与以下代码示例类似:
backend app1_www
mode http
redirect scheme https if !{ ssl_fc }
server localhost:3000 127.0.0.1:3000 check