大网数据广告活动
服务器运维问答

SSL offloading for multiple domains (multiple certs) on Haproxy

· 52CE 我爱测

Let's say that we have haproxy in front of 2 apache: +----> Apache (10.0.0.2) Haproxy (10.0.0.1) --| +----> Apache (10.0.0.3) Haproxy is configured to load balance traffic based on URI (needs to see URI so have to see content of …

问题原文

原帖链接 · gr0bz · CC BY-SA 3.0

Let's say that we have haproxy in front of 2 apache:

                     +----> Apache (10.0.0.2)
Haproxy (10.0.0.1) --|
                     +----> Apache (10.0.0.3)
  • Haproxy is configured to load balance traffic based on URI (needs to see URI so have to see content of HTTP)
  • Apache is hosting a large amount of domains
  • Every domain is accessible in HTTPS via haproxy that offloads SSL and initiate HTTP connection to Apache
  • Every domain has its own SSL certificate (no SAN or wildcard cert)

I saw that Haproxy allows us to give a directory with many certificates but I didn't manage to make it work with another thing that a single certificate.

Here is my (simplified) configuration:

global
        [...]
        # Default SSL material locations
        ca-base /etc/ssl/certs
        crt-base /etc/ssl/private

        # Default ciphers to use on SSL-enabled listening sockets.
        ssl-default-bind-options no-sslv3
        ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS

        # For backends connections
        ssl-default-server-options no-sslv3
        ssl-default-server-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS

frontend https_frontend
        bind 10.0.0.1:443 ssl crt /etc/ssl/private/mycerts/mydomain.pem # HERE WE WANT A DIRECTORY INSTEAD OF A FILE
        default_backend apache_backend

backend apache_backend
        cookie SRVID insert indirect nocache

        # Backends
        server apache1 10.0.0.2:80 check maxconn 64
        server apache2 10.0.0.3:80 check maxconn 64

        # Load Balancing - URI Consistent
        balance uri
        hash-type consistent

        # Options
        option http-keep-alive

已采纳解答

原帖链接 · Pablo Martinez · CC BY-SA 3.0

You could use the crt-list and point to a file containing the list of certificates, so your frontend would read as

frontend https_frontend
    bind 10.0.0.1:443 ssl crt-list /etc/ssl/private/mycerts.txt
    default_backend apache_backend

And to generate the list just with something like find /etc/ssl/private/mycerts/ > /etc/ssl/private/mycerts.txt. See more information in https://cbonte.github.io/haproxy-dconv/configuration-1.6.html#5.1-crt-list

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-10)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。