Answer the question
In order to leave comments, you need to log in
What's wrong with the config, HTTPS doesn't work?
I've been racking my brains for half a day, it doesn't work for the life of me.
exactly the same config from another site (on the same server) works - this one does not work
1. Does not pass validation here https://hstspreload.org/
2. swears that the www subdomain does not correspond to a certificate (although physically it is there is a server) but on mysite.com
3. how to issue a certificate to the www domain if it is explicitly specified without www in the config, how does another site work then? With the same config, it passes the hstspreload.org validation without any problems
4. maybe this hsts and the www domain?
Where is the mistake
server {
if ($host = www.mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = mysite.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name mysite.com www.mysite.com;
return 301 https://mysite.com$request_uri;
}
server {
listen 443 ssl http2;
server_name mysite.com www.mysite.com;
add_header Strict-Transport-Security 'max-age=31536000; includeSubDomains; preload';
ssl_certificate /etc/letsencrypt/live/mysite.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/mysite.com/privkey.pem; # managed by Certbot
ssl_trusted_certificate /etc/letsencrypt/live/mysite.com/chain.pem;
include /etc/letsencrypt/options-ssl-nginx.conf;
root /var/www/mysite.com/web;
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