I'm using nginx and I want to know if it's possible to do this.
Now to manage my vhost, I create them separately in /etc/nginx/sites-available (activate them after)
mydomain.com
subdomain.mydomain.com
subdomain1.mydomain.com
anotherdomain.com
So to redirect http to https I create a redirect vhost, that contain :
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
mydomain.com and all other subdomain are under https.
But the problem is anotherdomain.com, I don't want to redirect it to https. And here I don't know how to do this. I've got an idea :
Create only on vhost, that contain all the config, and do this :
# Config of anotherdomain.com
# Redirect all domain/subdomain after this part to https
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 301 https://$host$request_uri;
}
# Config of mydomain.com
# Config of subdomain.com
# Config of subdomain1.com
This will work as a kind of override, like in CSS ?
Thanks for your feedback.