Hello,
I’m using Nginx.
I registered my domains ‘domain.com’ ‘www.domain.com’ using certbot :
/opt/certbot-auto certonly --webroot -w /var/www/ -d www.domain.com -d domain.com
I configured Nginx like that :
server {
listen 80;
server_name domain.com www.domain.com;
location ^~ /.well-known/ {
root /var/www;
}
location / {
return 301 https://www.domain.com$request_uri;
}
}
server {
listen 443 ssl;
server_name www.domain.com;
root /var/www/domain;
index index.html;
location ^~ /.well-known/ {
root /var/www;
}
location ~ /\. {
return 404;
}
ssl on;
ssl_certificate /etc/letsencrypt/live/www.domain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.domain.com/privkey.pem;
ssl_prefer_server_ciphers on;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
}
My problem is : when I access https://domain.com, it does not redirect me to https://www.domain.com.
How can I solve my problem ?