第一:


if ($scheme = http ) {
return 301 https://$host$request_uri;
}

#or

if ($server_port = 80 ) {
return 301 https://$host$request_uri;
}

第二:

rewrite ^(.*)$  https://$host$1 permanent;  

 

第三:

return 301 https://$server_name$request_uri;