http跳转https

1、第一种:不好使

在nginx的配置中,在https的server站点添加如下头部:

add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

这样当第一次以https方式访问我的网站,nginx则会告知客户端的浏览器,以后即便地址栏输入http,也要浏览器改成https来访问我的nginx服务器。

原文链接:https://blog.csdn.net/socho/article/details/72456008

复制代码
server {
        listen       443 ssl;
        listen       [::]:443 ssl;
        server_name  beta.deepcloudsdp.com saas2.deepcloudsdp.com;
        add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
#        ssl on;
        ssl_certificate      /project/redcore/base/nginx/conf/SSL/cert.pem;
        ssl_certificate_key  /project/redcore/base/nginx/conf/SSL/privkey.pem;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

2、第二种

复制代码
server {
        listen       80;
        listen [::]:80;
        server_name  saas2.deepcloudsdp.com;
        rewrite ^(.*)$  https://$host$1 permanent;    # 这行
        #rewrite ^/(.*) https://$server_name/$1 permanent;  # 或这样
        root /project/redcore/webRoot/public;
        index index.html;

        proxy_set_header X-Real-IP $remote_addr;

        location ~* /client/v[345]/push/sse {
           rewrite /client/v[345]/push(.*) $1 break;
           proxy_pass http://172.17.123.5:8181;
           proxy_set_header Connection '';
           proxy_http_version 1.1;
           chunked_transfer_encoding off;
           proxy_buffering off;
           proxy_cache off;
           proxy_read_timeout 600s;
           proxy_connect_timeout 600;
        }
相关推荐
XUEYUAN52125 天前
ASN 自治系统号风控:平台如何通过 IP 所属自治域批量识别代理流量
python·网络协议·http·网络安全·socks5
CHENKONG_CK6 天前
破解制鞋打磨痛点:RFID赋能去毛刺工序自动化升级
网络·单片机·嵌入式硬件·网络协议·tcp/ip
2501_916007476 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
Lsetea6 天前
证书没到期却报certificate has expired:OpenSSL定位中间证书与系统时间
运维·https·ssl证书·openssl·证书链
z落落6 天前
C#UDP+串口服务端+UDP 客户端(含 CRC16 校验)
网络·网络协议·udp
2501_916008896 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
SDWAN_Cheap6 天前
HTTPS到底加密了什么?
https·数据加密
曼巴UE56 天前
UE5 客户端 需要的网络同步概念总结(3 )-事件同步 RPC 以及三种调用方式
网络·c++·网络协议·学习·rpc·ue5
captain3766 天前
HTTP(2)
java·网络·http·java-ee
开开心心就好6 天前
安卓手写文字生成工具,多种纸张一直免费
网络·网络协议·tcp/ip·leetcode·智能手机·电脑·模拟退火算法