I have an ec2 instance running ubuntu and nginx 0.8.4, with vhosts serving several different domains using http but one using SSL/https.
Secure domain configuration:
server {
listen 443 ssl;
server_name "securedomain.tld";
ssl_certificate /etc/nginx/certs/securedomain.tld.crt;
ssl_certificate_key /etc/nginx/certs/securedomain.tld.key;
if ($host != $server_name) {
return 444; # this won't work because HTTPS communication has
# been already started, warning message is displayed
}
// ...
}
Unsecure domain configuration:
server {
listen 80;
server_name "unsecuredomain.tld";
// ...
}
Right now the domain served using https is catching up all the https trafic, for all managed domains… that means that https://unsecuredomain.tld/ will display a warning and actually serve the contents from securedomain.tld
:(
Question is, is there a way to prevent nginx from serving all unsecure domains served using https? eg by specifying that you only want to accept https connections for a given requested host…
Hint: an ec2 instance cannot have more than one IP affected.