赞
踩
1、haproxy 本身提供ssl 证书,后面的web 服务器走正常的http (偷懒方式)
2、haproxy 本身只提供代理,后面的web服务器https
需要编译haproxy 支持ssl,编译参数:
- make TARGET=linux3100 USE_OPENSSL=1 ADDLIB=-lz
- ldd haproxy | grep ssl
- libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007fb0485e5000)
- 新建用户
- useradd -s /sbin/nologin -M haproxy
配置参数:
- 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 example.com.crt example.com.key > example.com.pem
- cat /etc/pki/dashboard.crt /etc/pki/dashboard.key | tee /etc/pki/dashboard.pem
- 这一步使用手动合并使用nodepad++
运行
./haproxy -f conf/haproxy.cfg
不需要重新编译支持ssl,简单方便。需要后面的web服务器配置好ssl 即可。
- 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
这一行是仅支持ssl,效果是:访问80端口是自动跳转到443的ssl
这是针对node生效,如果想全局使用的话,可以把这句话添加到frontend下
这是针对node生效,如果想全局使用的话,可以把这句话添加到frontend下
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。