Haproxy 版本需要在1.5以上才支持SSL
haproxy 代理 ssl 有兩種方式
1、haproxy 本身提供ssl 證書,後面的web 服務器走正常的http ,這種方式需要重新編譯haproxy
2、haproxy 本身只提供代理,後面的web服務器https,這種方式不需要重新編譯
方式一:
重新編譯安裝
make TARGET=linux3100 USE_OPENSSL=1 ADDLIB=-lz clean all make install [root@localhost haproxy]# ldd haproxy | grep ssl libssl.so.10 => /lib64/libssl.so.10 (0x00007f5ab8264000)
修改haproxy.cfg配置文件
global tune.ssl.default-dh-param 2048 //修改默認使用2048bit加密,不設置會有警告 frontend http-in bind *:443 ssl crt /root/server.pem //配置ssl支持,這裏pem文件是證書和私鑰合併而成的, cat servername.crt servername.key |tee servername.pem reqadd X-Forwarded-Proto:\ https //http和https並存 redirect scheme https if !{ ssl_fc } //http跳轉https
方式二:
需要後置服務器本身支持https,那麼只要進行如下配置: frontend https bind *:443 mode tcp default_backend weblogic backend weblogic mode tcp balance source server s1 10.20.2.233:443 注意,這種模式下mode 必須是tcp 模式