haproxy ssl 支持

参考配置

global
     log         127.0.0.1 local2
    tune.ssl.default-dh-param 2048 # 此选项还是比较重要的,不然会有提示信息的(主要是安全问题)
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon
    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000
 
frontend  main
    bind :80    
    bind :443 ssl crt /etc/haproxy/app.pem  # 证书文件,注意是包含了证书公钥以及私钥的合并(使用 cat 组合就可以了。。)
    default_backend             app
backend app
    server  app1 127.0.0.1:8080

说明

核心比较简单,主要是ssl 以及crt 配置,如果需要支持http2的话,就需要添加 alpn h2,http/1.1 了(最好同时支持http1.1 以及http2)
对于crt 需要是合并的,通过cat 或者复制到一起就行了

参考资料

https://www.haproxy.com/blog/haproxy-ssl-termination/
https://ssl-config.mozilla.org/
https://www.haproxy.com/documentation/hapee/latest/load-balancing/protocols/http-2/

posted on 2021-12-03 22:20  荣锋亮  阅读(128)  评论(0编辑  收藏  举报

导航