Answer the question
In order to leave comments, you need to log in
Two SSL sites on NGINX. Why does www redirect to a neighboring site?
Good afternoon, there are 2 sites with SSL certificates.
Problem:
If the request is:
curl -I https://www.1111.com ответ правильный: https://1111.com
curl -I https://www.2222.com ответ:
(curl: (51) SSL: no alternative certificate subject name matches target host name 'www.1111.com')
curl -I http://www.2222.com ответ: https://1111.com
server {
listen 80;
server_name 1111.com www.1111.com;
return 301 https://1111.com;$request_uri;
}
server {
listen 443 ssl http2;
server_name 1111.com;
root /usr/share/nginx/1111.com;
index index.php;
...
Answer the question
In order to leave comments, you need to log in
Here is the correct setting:
server {
listen 80;
server_name site.ru www.site.ru;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen 443 ssl http2;
include ssl/ssl_site.ru;
server_name www.site.ru;
rewrite ^(.*) https://site.ru$1 permanent;
}
server {
listen 443 ssl http2;
server_name site.ru;
include ssl/ssl_site.ru;
... other config string ...
Or like this:
server {
listen %ip%:%web_port%;
server_name %domain_idn% %alias_idn%;
return 301 https://%domain_idn%$request_uri;
}
server {
listen %ip%:%web_ssl_port% http2 ssl;
server_name %alias_idn%;
return 301 https://%domain_idn%$request_uri;
ssl on;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
}
server {
listen %ip%:%web_ssl_port% http2 ssl;
server_name %domain_idn%;
root %sdocroot%;
index index.php index.html index.htm;
ssl on;
ssl_certificate %ssl_pem%;
ssl_certificate_key %ssl_key%;
location / {
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question