nginx 强制访问https

使用nginx的301状态码:

server {

            listen 80;

            listen 443;

            server_name xxx.com;

            ssl   on;

            ssl_certificate    /data/www-key/xxx.pem;

            ssl_certificate_key    /data/www-key/xxx.key;

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

}

Enjoy it !

posted @ 2020-10-29 16:51  酷极和  阅读(196)  评论(0编辑  收藏  举报