一、haproxy 自己提供ssl 證書,後面的web 服務器走正常的http linux
二、haproxy 自己只提供代理,後面的web服務器httpsweb
須要編譯haproxy 支持ssl,編譯參數: 服務器
make TARGET=linux26 USE_OPENSSL=1 ADDLIB=-lz ldd haproxy | grep ssl libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fb0485e5000)
配置參數:cookie
frontend https_frontend bind *:443 ssl crt /etc/ssl/certs/servername.pem mode http option httpclose option forwardfor reqadd X-Forwarded-Proto:\ https default_backend web_server backend web_server mode http balance roundrobin cookie SERVERID insert indirect nocache server s1 192.168.250.47:80 check cookie s1 server s2 192.168.250.49:80 check cookie s2 注意:這裏的pem 文件是下面兩個文件合併而成: cat servername.crt servername.key |tee servername.pem
不須要從新編譯支持ssl,簡單方便。須要後面的web服務器配置好ssl 便可。
frontend
frontend https_frontend bind *:443 mode tcp default_backend web_server backend web_server mode tcp balance roundrobin stick-table type ip size 200k expire 30m stick on src server s1 192.168.250.47:443 server s2 192.168.250.49:443 注意,這種模式下mode 必須是tcp 模式
http://virtuallyhyper.com/2013/05/configure-haproxy-to-load-balance-sites-with-ssl/ tcp
http://www.rackspace.com/knowledge_center/article/setting-up-haproxyspa