nginx 配置实现网站强制 https访问 (基于HSTS) 307

首先,相关的介绍不在此处赘述,请参考:

https://blog.csdn.net/luyaran/article/details/77744239

https://cloud.tencent.com/developer/article/1153899

如何实现

1.实现的前提是当前网站已经可以使用https访问,ssl证书都已经存在

在nginx配置如下

server {
    listen 443 ssl;
    server_name desktop.efcore.cn;
    add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
    add_header X-Frame-Options "DENY";
    ssl on;
    ssl_certificate 1_desktop.efcore.cn_bundle.crt;
    ssl_certificate_key 2_desktop.efcore.cn.key;
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    root /usr/local/angular/oa/dist/ng-oa/;

    location / {
        try_files $uri $uri/ /index.html;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

server {
    listen 80;
    server_name desktop.efcore.cn;
    add_header X-Frame-Options "DENY";
    return 301 https://desktop.efcore.cn/index.html;
}
 

阅读更多
换一批

没有更多推荐了,返回首页