I've seen two ways nginx is used to redirect http to https:
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com
location / {
return 301 https://$host$request_uri;
}
}
and
server {
listen 80;
listen [::]:80;
server_name example.com www.example.com
return 301 https://$host$request_uri;
}
What is the difference between these? Is there a reason to use the one or the other?