njsuntop 发表于 2019-1-2 08:52:24

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
  frontendmain *:80
stats   uri         /haproxy?stats
default_backend             http
  backend http
balance   roundrobin
server10.0.0.3 10.0.0.3:80 check
server10.0.0.4 10.0.0.4:80 check

    frontendmain *:443
mode tcp
default_backend             https
  backend https
mode tcp
balance   roundrobin
server10.0.0.3 10.0.0.3:443 check
server10.0.0.4 10.0.0.4:443 check
  :wq

service haproxy restart
  验证:
  浏览器访问:http://xxxx(推荐域名访问),https://xxxxx
  haproxy状态页面:http://xxxx/haproxy?stats(可以看http和https分配情况)



页: [1]
查看完整版本: HAProxy同时对80和443做负载均衡