可以把所有的HTTP请求通过rewrite重写到HTTPS上
server{
listen 80;
server_name XXXXX.com; //你的域名
//rewrite ^(.*)$ https://XXXXXX.com permanent;
rewrite ^(.*)$ https://$host$1 permanent;
location ~ / {
index index.html index.php index.htm;
}
}
server{
listen 80;
server_name XXXXX.com; //你的域名
return 301 https://$server_name$request_uri;
location ~ / {
index index.html index.php index.htm;
}
}