server {
listen *:80;
server_name www.domain.com domain.com;
location / {
rewrite ^(.*)$ https://www.domain.com$1 permanent;
}
}
server {
listen 80;
server_name www.domain.com domain.com;
return 301 https://www.domain.com$request_uri ;
}
server {
listen 443 ssl;
server_name domain.com;
return 301 https://www.domain.com$request_uri ;
}
server {
listen 443 ssl;
server_name www.domain.com domain.com;
# основная секция
}