I have two sites in the same IP with the follow configuration:
- site1.com
- Multiples subdomains (ie.: foo.site1.com, bar.site1.com)
- Everything listening on port 80, NOTHING in 443
- site2WithSSL.com
- Listening on ports 80 and 443 (SSL)
I can access to https://site2WithSSL.com and to http://site1.com without problems. The issue comes when someone want to access to https://site1.com, nginx answers with the site2WithSSL.com I want to avoid this. I mean, whenever somebody access to https://site1.com no content has to be returned or just a redirect to https://
The configuration is:
server {
listen 80;
server_name *.site1.com;
// ...
}
server {
server_name www.site2WithSSL.com;
return 301 $scheme://site2WithSSL.com$request_uri;
}
server {
listen 80;
listen 443 ssl;
server_name site2WithSSL.com;
ssl_certificate site2WithSSL.crt;
ssl_certificate_key site2WithSSL.key;
// ...
}
SOLVED: using a different ip for each site