为80端口的http站点添加如下的语句即可强制HTTPS
return 301 https://$server_name$request_uri

全文如下

1
2
3
4
5
server {
listen 80;

return 301 https://$server_name$request_uri;
}