您的位置:首页 > 其它

HAProxy同时对80和443做负载均衡

2018-08-10 09:34 330 查看

HAProxy同时对80和443做负载均衡:

注:
1、该操作依据Redhat/CentOS 6系统
2、https使用mode tcp(不需要配置crt,使用实际web的crt)
3、需注掉option httplog和option forwardfor except 127.0.0.0/8

vi /etc/haproxy/haproxy.cfg

option httplog

option forwardfor except 127.0.0.0/8

frontend main *:80
stats uri /haproxy?stats
default_backend http

backend http
balance roundrobin
server 10.0.0.3 10.0.0.3:80 check
server 10.0.0.4 10.0.0.4:80 check

frontend  main *:443
mode tcp
default_backend             https

backend https
mode tcp
balance roundrobin
server 10.0.0.3 10.0.0.3:443 check
server 10.0.0.4 10.0.0.4:443 check

:wq

service haproxy restart

验证:

浏览器访问:http://xxxx (推荐域名访问),https://xxxxx

haproxy状态页面:http://xxxx/haproxy?stats (可以看http和https分配情况)

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息