server {
listen 80;
listen [::]:80 default_server ipv6only=on;
server_name example.com www.example.com
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.example.com;
ssl_certificate chain.pem;
ssl_certificate_key key.pem;
return 301 https://example.com$request_uri;
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name example.com;
ssl_certificate chain.pem;
ssl_certificate_key key.pem;
location / {
......
}
}