haproxy 配置https 同时技持443 80端口

 确定haproxy支持https

[root@c01 sbin]# ldd haproxy |grep ssl
	libssl.so.10 => /usr/lib64/libssl.so.10 (0x00007f961911c000)

整合证书和私钥:

# cat 213978673141013.key 213978673141013.pem |tee server.pen

查看配置文件:

    global
            log 127.0.0.1 local0 info #[err warning info debug] //日志位置  
            tune.ssl.default-dh-param 2048 #修改默认使用2048bit加密,不设置会有警告
            maxconn 4096
            daemon #设置成后台运行  
            nbproc 1 #进程数量  
            pidfile /apps/haproxy-1.7.7/haproxy.pid

    defaults
            log     global
            mode    http #默认模式  
            option  httplog #http日志格式  
            option  dontlognull
            retries 3  #三次失败后认为服务器不可用  
            option  redispatch  #如果cookie写入了serverId而客户端不会刷新cookie,当serverId对应的服务器挂掉后,强制定向到其他健康的服务器  
            maxconn 2000 #当服务器负载很高的时候,自动结束掉当前队列处理比较久的链接默认的最大连接数  
            contimeout 5000 #连接超时  
            clitimeout 30000 #客户端超时  
            srvtimeout 30000 #服务器超时  

    frontend web_in
            mode http
            maxconn 1000
            bind *:80 
            bind *:443 ssl crt /etc/cert/server.pem 
            reqadd X-Forwarded-Proto: https #HTTP,HTTPS并存
            #redirect scheme https if !{ ssl_fc } 
            acl is_a hdr_beg(host) -i ssl.espressos1.com  #判断域名是不是www.espressos1.com,是则给与a服务器集群服务  

            use_backend a_server if is_a
      
    backend a_server  
            mode http #http 模式  
            stats   uri  /haproxy  
            balance roundrobin
            cookie  JSESSIONID prefix  
            stats   hide-version
            option  httpclose  
            server web1 10.100.0.220:80 check
            #server web2 128.1.2.5:80 check 
原文地址:https://www.cnblogs.com/bass6/p/7131671.html