Configure Multiple Domain In Ngnix
The key is using the SNI.
Pre-work
Check if your nginx support SNI.
1 | nginx -V |
If the output is TLS SNI support enabled, it means your nginx has enabled SNI.
Configure
There are two types below for configuring multiple domains with https in this article.
non terminating, TLS pass through
Pass the TLS stream to an upstream server, based on the domain name from TLS SNI field. This does not terminate TLS.
The upstream server can serve HTTPS or other TLS secured TCP responses.
1 | stream { |
terminating TLS, forward TCP
Terminate TLS and forward the plain TCP to the upstream server.
1 | stream { |
Note:
This method is strictly to verify ssl certifations. It will have an impact on your CNAME.
References
- https://nginx.org/en/docs/http/configuring_https_servers.html
- https://gist.github.com/kekru/c09dbab5e78bf76402966b13fa72b9d2
This blog is under a CC BY-NC-SA 3.0 Unported License
Link to this article: https://younggod.netlify.app/2021/05/16/Practice/nginxWithMultipleDomain/