Nginx-强制使用443-SSL

rewrite 重写URL实现

server {
listen 80;
server_name localhost;
rewrite ^(.*)$ https://$host$1 permanent;
}

301 重定向实现

server {
    listen 80;
    server_name *.codelinux.cn;
    return 301 https://$http_host$request_uri;
}