HTTPS 站点请求 HTTP的API 接口服务报错的问题

问题

线上部署一功能服务时,部署后使用postman调用接口测试正常,在线上系统中调用时出现接口无法请求通过的现象。

经排查发现,在console中出现了**This request has been blocked; the content must be served over https ;**的错误警告。

引发原因

线上系统为https站点,而部署的服务接口使用的是http请求。在线上系统请求服务接口引发了该错误,https站点无法访问http请求的错误;

HTTPS页面里动态的引入HTTP资源,比如引入一个js文件,会被直接block掉.在HTTPS页面里通过AJAX的方式请求HTTP资源,也会被直接block掉。

解决

方案一

将接口服务改造成使用https 的服务

方案二

采用nginx转发。将该服务接口使用nginx已经配置ssl的监听端口去进行转发操作,只需要配置一项反向代理即可实现。

此处使用了线上的443端口进行转发。

bash 复制代码
# HTTPS server
#   
server {
    listen       443 ssl;
    server_name  myhttps;
    root /opte/web;
     ssl_certificate      /opte/nginx/conf/FKWE.crt;
     ssl_certificate_key  /opte/nginx/conf/FKWE.key;
#    ssl_session_cache    shared:SSL:1m;
#    ssl_session_timeout  5m;

    ssl_ciphers  HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on; 

    location / { 
        root   /opte/web;
        index  index.html index.htm index.php;
    }   
    location ~ \.php$ {
        #root           /opte/web/;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
    } 

   # 证书登陆 
    location /jit/ {
        proxy_pass http://127.0.0.1:8083/jitsss/;
    }   

}   
相关推荐
王二端茶倒水12 小时前
宽带无线项目,怎么从一次性交付变成长期运营收入?
网络协议
Goodbye13 小时前
大模型无状态架构:从 HTTP 协议到 Harness AI 工程的深度解析
http
Avan_菜菜1 天前
FRP 内网穿透完整实战:从 HTTP 映射到 HTTPS 自签代理
运维·nginx·https
用户2530171996272 天前
第6篇:从技术到产品 — Ghost Proxifier 的设计哲学
网络协议
用户2530171996272 天前
第3篇:注入的艺术 — Ghost Proxifier 核心架构拆解
网络协议
王二端茶倒水3 天前
商业 WiFi 不是免费上网,而是门店数字化的入口
网络协议
霜落长河7 天前
抛弃TCP改用UDP,HTTP3怎么了?
http
程序员mine8 天前
HTTPS-TLS加密与证书完全指南(中)
网络协议·https·ssl
之歆8 天前
现代 HTTP 客户端深度解析:Fetch 与 Axios
chrome·网络协议·http