Forked from hxyconan/haproxy_ssl_request_passthrough_ver2.txt
Created
March 12, 2024 17:31
-
-
Save petarbojic/97a6d84a7e09c6f4cfafb1d297e0bb0e to your computer and use it in GitHub Desktop.
Haproxy configuration for SSL request passthrough to different backend based on SNI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Haproxy configuration for SSL request passthrough to different backend based on SNI read from Handshaking stage | |
# The Loadbalance will not decode the encrpted data but transparently transfer to the backend server in Private subnet. | |
# With such configuration, you can install multiply services with its own SSL certificate in backend in different EC2 instance, but only explosure to public internet with one Loadbalance IP. There is no need to install SSL certificate in Loadbalancer level. | |
# Ref: | |
# How to support wildcard sni: https://stackoverflow.com/questions/24839318/haproxy-reverse-proxy-sni-wildcard | |
# https://www.haproxy.com/blog/enhanced-ssl-load-balancing-with-server-name-indication-sni-tls-extension/ | |
# https://stuff-things.net/2016/11/30/haproxy-sni/ | |
#--------------------------------------------------------------------- | |
# Proxys to the webserver backend port 443 | |
#--------------------------------------------------------------------- | |
frontend main_ssl | |
bind :443 | |
mode tcp | |
option tcplog | |
# Wait for a client hello for at most 5 seconds | |
tcp-request inspect-delay 5s | |
tcp-request content accept if { req_ssl_hello_type 1 } | |
use_backend aaa_ssl if { req_ssl_sni -m end .aaa.domain.com } | |
use_backend bbb_ssl if { req_ssl_sni -m end .bbb.domain.com } | |
default_backend static | |
backend aaa_ssl | |
mode tcp | |
balance roundrobin | |
server aaa_ssl_server x.x.x.x:443 check | |
backend bbb_ssl | |
mode tcp | |
balance roundrobin | |
server bbb_ssl_server x.x.x.x:443 check |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment