Replies: 1 comment
-
|
There are really two ways to make this happen: 1. Do a straight TCP/TLS pass-through (so the container itself handles TLS and SNI)In this model, nginx never terminates the client's TLS on port 443. We just let the TCP handshake (including TLS ClientHello/SNI) go straight to the container. That way, the container's web server (Apache/Nginx/whatever inside the OS) sees the SNI exactly as the client sent it, chooses its own cert, and serves. How to set it up
2. Terminate TLS at nginx, then re-encrypt to the container ("TLS re-encrypt") and explicitly forward the original SNIIf we want nginx to terminate TLS (for logging, filtering, WAF, Let's Encrypt automation, etc.), but still let the upstream service see the client's hostname, we can "re-encrypt" from nginx to container and tell nginx to use the same server_name on the upstream TLS handshake. In other words, nginx is acting as both an HTTPS server (for the client) and as an HTTPS client (for the container). Steps to re-encrypt with SNI preservation
Which approach should we pick?
Example snippet: re-encrypting HTTPS with SNIBelow is a minimal example of how the http {
# (1) Define an upstream pointing at the container's TLS port
upstream mycontainer {
server 10.0.1.5:8443; # container's private IP: TLS port
}
# (2) The server block that listens for public HTTPS
server {
listen 443 ssl;
server_name host1.example.com host1-alias.com; # allow multiple domains
# These live on the reverse-proxy host
ssl_certificate /etc/letsencrypt/live/host1.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/host1.example.com/privkey.pem;
# (3) Optional: any TLS settings (protocols, ciphers, HSTS, etc.)
location / {
# pass traffic to the container over HTTPS
proxy_pass https://mycontainer;
proxy_http_version 1.1;
proxy_set_header Host $host;
# THIS is the magic that pushes the same SNI downstream:
proxy_ssl_server_name on;
proxy_ssl_name $host;
# (if the container's cert is self-signed, disable verification or provide CA):
proxy_ssl_verify off;
# or:
# proxy_ssl_verify on;
# proxy_ssl_trusted_certificate /etc/nginx/ssl/ca.pem;
}
}
}
Final notes
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
For OS apps we could investigate allowing multiple domains per app.
The main challenge will be TLS termination at the reverse proxy, we need to see how we can keep SNI when calling the upstream.
Beta Was this translation helpful? Give feedback.
All reactions