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

}   
相关推荐
发光小北20 小时前
西门子 PLC 串口转网口模块现场应用有哪些问题?
网络协议
楚Y6同学1 天前
QT上位机开发-UDP通信-模拟下位机数据联调的方法
网络协议·udp·联调方法
captain3761 天前
网络原理(3)-TCP核心机制连接管理▲▲▲
java·服务器·网络·ide·网络协议·tcp/ip·java-ee
易岳群1 天前
搞清 Socket、TCP、MQTT 的通信关系:从底层协议到物联网实战
网络协议·tcp/ip·socket·通信协议关系
宵时待雨1 天前
linux笔记归纳19:网络层协议IP
linux·网络·笔记·网络协议·tcp/ip
只睡四小时1 天前
内网穿透+WebSocket:Node 零依赖远程桌面实战
网络·websocket·网络协议
Jeremy_WW1 天前
802.3协议解读 05:116章节 200 Gb/s 和 400 Gb/s 网络介绍 V
网络·网络协议·信息与通信·光模块·802.3协议
梦想平凡1 天前
百游棋牌源代码开发搭建教程(七):WebSocket房间同步与断线恢复
网络·websocket·网络协议
Lsetea1 天前
Java 请求 HTTPS 报 PKIX path building failed:从证书链到 truststore 的完整排查
java·https·ssl证书·keytool·truststore
Lhappy嘻嘻1 天前
网络(六)|应用层 HTTP&HTTPS:URL、请求响应、Cookie 与证书
网络·http·https