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

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分配情况)

相关文章
相关标签/搜索