So I've got a server with a single IP and a lot of websites, all hosted under nginx. Here's a very simplified reduction of my actual setup:
server {
listen 80;
listen 443 ssl;
server_name ssl.example.com;
#...
}
server {
listen 80;
server_name nossl.example.com;
#...
}
If I connect to ssl.example.com:443
everything works, as expected.
If I connect to nossl.example.com:443
, it tries to serve the content of ssl.example.com:443
.
I've made my peace with the why that happens (it's just how ssl+nginx best-matches a virtual server), I just need to stop it sending content from the wrong site.
Short of buying certificates for all my sites (or issuing my own), or pushing the SSL site off onto its own IP, what are my options here? Can nginx double-check the domain for every SSL request and make sure it matches that server_name
?