I setup a redirect for all HTTP traffic on my subdomain to go through HTTPS but I noticed that when I visit http://mydomain.com
it is redirecting to https://subdomain.mydomain.com
. No problem is encountered on https://mydomain.com
.
Just to clarify,
http://mydomain.com
should not redirect but it currectly redirects to https://subdomain.mydomain.com
http://subdomain.mydomain.com
should redirect to https://subdomain.mydomain.com
.
This is my nginx conf
server {
listen *:80;
server_name subdomain.mydomain.com;
server_tokens off;
root /nowhere; # this doesn't have to be a valid path since we are redirecting, you don't have to change it.
rewrite ^ https://$server_name$request_uri permanent;
}
server {
listen 443 ssl;
server_name subdomain.mydomain.com;
server_tokens off;
.... other stuff ...
}
mydomain.com
?mydomain.com
that prints a default message or something.