두 개의 다른 SSL 인증서로 HAProxy를 구성해야합니다
- www.example.com
- api.example.com
이제 serverfault ( Haproxy에서 여러 SSL 인증서 구성) 게시물에서 2 개의 인증서를 사용하는 방법을 배웠지 만 서버는 두 도메인 모두에서 언급 된 첫 번째 인증서를 계속 사용합니다.
구성 :
frontend apache-https
bind 192.168.56.150:443 ssl crt /certs/crt1.pem crt /certs/cert2.pem
reqadd X-Forwarded-Proto:\ https
default_backend apache-http
backend apache-http
redirect scheme https if { hdr(Host) -i www.example.com } !{ ssl_fc }
redirect scheme https if { hdr(Host) -i api.example.com } !{ ssl_fc }
...
URL에 따라 사용할 인증서를 HAProxy에 알리는 방법은 무엇입니까?
전체 구성 :
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
ssl-default-bind-options no-sslv3
tune.ssl.default-dh-param 2048 // better with 2048 but more processor intensive
defaults
log global
mode http
option tcplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
frontend apache-http
bind 0.0.0.0:80
mode http
option http-server-close # needed for forwardfor
option forwardfor # forward IP Address of client
reqadd X-Forwarded-Proto:\ http
default_backend apache-http
stats enable
frontend apache-https
bind 0.0.0.0:443 ssl crt cer1.pem cert2.pem
reqadd X-Forwarded-Proto:\ https
default_backend apache-http
backend apache-http
redirect scheme https if { hdr(Host) -i db.example.com } !{ ssl_fc }
redirect scheme https if { hdr(Host) -i api2.example.com } !{ ssl_fc }
balance roundrobin
cookie SERVERID insert indirect nocache
server www-1 10.0.0.101:80 cookie S1 check
server www-2 10.0.0.102:80 cookie S2 check
server www-3 10.0.0.103:80 cookie S3 check
답변
HAProxy 1.6 이상을 실행 중인지 확인하십시오.
이 질문은 조금 오래되었지만 OP와 비슷한 구성 에서이 동일한 문제에 부딪 쳤습니다.
HAProxy 1.5는 옵션 에서 다중 crt
구문을 허용합니다 bind
. 그러나 응답 할 때 첫 번째 인증서 만 사용합니다.
HAProxy 1.6은 호출자의 요청에 따라 인증서로 응답하는 것으로 보입니다. 이것은 sni
구성에 특별한 ACL 이 필요하지 않은 것으로 보입니다 .
다음은 1.6에서 작동하지만 1.5 cert2.pem
에서 요청에 응답 할 때 사용되지 않는 예입니다 place2.com
.
frontend http-in
bind *:80
bind *:443 ssl crt cert1.pem crt cert2.pem
mode http
acl common_dst hdr(Host) -m str place1.com place2.com
use_backend be_common if common_dst
backend be_common
# nothing special here.
답변
어떤 인증서 haproxy가 있는지 테스트하고 있습니까? 을 사용하는 경우 어떤 프록시가 어떤 인증서를 제공할지 결정해야하는 SNI 정보를 보내려면 openssl s_client
추가 매개 변수 ( -servername api.domain.com
)가 필요합니다.