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;
}
 

©️2020 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客 返回首页
实付0元
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值