配置Nginx部署静态资源和自动跳转到https

wylc123 1年前 ⋅ 709 阅读
server {
        listen 80;
        server_name www.locusy.top;
        root /www/temp/blog/public/client;
        index index.html;
        location ~ .*\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt)$ {
                root /www/temp/blog/public;
        }
        rewrite ^(.*)$  https://$host$1 permanent; #设置http跳转https
#       return 301 https://www.locusy.top$request_uri;
}

server {
        listen 443;
        server_name www.locusy.top;
        ssl on;
        ssl_certificate   cert/1652724_www.locusy.top.pem;
        ssl_certificate_key  cert/1652724_www.locusy.top.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        #配置静态网站地址
        root /www/temp/blog/public/client;
        index index.html;
        location ~ .*\.(jpg|jpeg|gif|png|ico|css|js|pdf|txt)$ {
                root /www/temp/blog/public;
        }
}
更多内容请访问:IT源点

相关文章推荐

全部评论: 0

    我有话说: