haproxy http 重定向 https
对于http端口:80,https端口:443
frontend app
bind *:80
bind :443 ssl crt /etc/haproxy/server.pem no-sslv3
mode http
option httplog
option forwardfor
rspidel ^Server.*
redirect scheme https if !{ ssl_fc }
default_backend app
backend app
mode http
option httpchk HEAD /
server app01 server1:3000 check inter 2000 rise 2 fall 5
对于http、https端口不为80、443时,以上的方法就行不通了,得使用下面的方法
frontend app
bind *:8080
bind :8443 ssl crt /etc/haproxy/server.pem no-sslv3
mode http
option httplog
option forwardfor
rspidel ^Server.*
http-request redirect code 301 location https://www.haxi.cc:8443%[capture.req.uri] if !{ ssl_fc }
default_backend app
backend app
mode http
option httpchk HEAD /
server app01 server1:3000 check inter 2000 rise 2 fall 5