Answer the question
In order to leave comments, you need to log in
How to configure nginx redirect to https only for the main domain?
Faced a strange problem. In a very typical scenario of a redirect from http to https (and from www to non-www), for some reason this config also affects other subdomains. For example, the sub.site.ru subdomain also starts redirecting to https, which does not have it.
server {
server_name site.ru www.site.ru;
listen *:80;
listen [::]:80;
return 301 https://site.ru$request_uri;
}
server {
# SSL configuration
listen 443 ssl;
listen [::]:443 ssl;
server_name site.ru;
...
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question