博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx修改webservice的WSDL
阅读量:4107 次
发布时间:2019-05-25

本文共 2782 字,大约阅读时间需要 9 分钟。

 

原项目的webservice,使用的是标准的http协议,最近进行安全检查,网站在负载均衡前面放置了证书完成了HTTPS改造,安全部门把目标盯在了还在用http协议传输的webservice接口。

网站改造了没问题,从HTTP、HTTPS协议上来看改成变更协议应该没问题,在webservice前端也放置了,证书,改走HTTPS协议,访问webservice地址,没有问题,执行报错了

查找错误原因,发现问题出现在wsdl身上

这段中的location还是使用的是http协议导致的问题,我将这个wsdl保存到本地,然后修改wsdl文件中的location部分为下面的内容:

然后使用本地的wsdl访问webservice服务,正常,那么现在问题能确认了就是wsdl的问题。

接下来该想如何解决了,之前做个一个类似的需求,当时使用的框架是spring cloud,在zuul里面讲response改写解决的,但是这个没有使用spring cloud的框架,无法使用zuul来解决了,考虑使用nginx来解决

道路是曲折的,过程是艰难的,结局是美好的。

下面来上最终配置

location / {            root   html;            index  index.html index.htm;	    sub_filter http://api.padis.scwjxx.cn:80 "https://api.padis.scwjxx.cn:80";	    sub_filter_once off;####所有匹配到的都替换        }        location /server {	#proxy_set_header Host $host:$server_port;	proxy_set_header Host $proxy_host;	proxy_pass  http://api.padis.scwjxx.cn;        proxy_redirect default;            root   wsdl;            #index  index.html index.htm;	    #index  *.html	    sub_filter http://api.padis.scwjxx.cn:80 "https://api.padis.scwjxx.cn:80";	    sub_filter_once off;####所有匹配到的都替换	    sub_filter_types text/xml; //关键        }

然后简要说下踩坑过程,一开始我先配置了location /中的,修改了index.html如下:

Welcome to nginx!

"http://api.padis.scwjxx.cn:80/server/LgProvinceService"

这里的关键配置是sub_filter_once off;####所有匹配到的都替换,没有添加这个配置的时候,只替换了<h1>标签中的内容,添加了这个配置之后,完美,所有的都没问题了,实验结束,正式开始解决问题

location /server {	#proxy_set_header Host $host:$server_port;	proxy_set_header Host $proxy_host;	proxy_pass  http://api.padis.scwjxx.cn;        proxy_redirect default;            root   wsdl;            #index  index.html index.htm;	    #index  *.html	    sub_filter http://api.padis.scwjxx.cn:80 "https://api.padis.scwjxx.cn:80";	    sub_filter_once off;####所有匹配到的都替换        }

按照实验进行了以下的参数调整,但是wsdl文件中的location内容没有变化,我一开始以为是root和index的问题,之前没有研究过nginx,后来看了文档发现跟这两兄弟没有关系,没有思路,继续读文档和sub_filter一起的是sub_filter_once和sub_filter_types,难道是sub_filter_types的问题,我观察了一下两次的请求的区别

第一次实验成功的html如下:

Connection: keep-aliveContent-Type: text/htmlDate: Tue, 02 Apr 2019 03:33:59 GMTServer: nginx/1.14.2Transfer-Encoding: chunked

 

第二次解决问题的response如下:

Connection: keep-aliveContent-Type: text/xml;charset=utf-8Date: Tue, 02 Apr 2019 03:50:04 GMTServer: nginx/1.14.2Transfer-Encoding: chunked

看出区别了吧,第一次的是text/html,第二次是text/xml,实话实说我一开始真没看出来,文档里写明了sub_filter_types默认是text/html,修改配置如下:

location /server {	#proxy_set_header Host $host:$server_port;	proxy_set_header Host $proxy_host;	proxy_pass  http://api.padis.scwjxx.cn;        proxy_redirect default;            root   wsdl;            #index  index.html index.htm;	    #index  *.html	    sub_filter http://api.padis.scwjxx.cn:80 "https://api.padis.scwjxx.cn:80";	    sub_filter_once off;####所有匹配到的都替换	    sub_filter_types text/xml;        }

重新实验,发现location已经变化,问题解决。

wsdl正常,webservice正常了

 

转载地址:http://awtsi.baihongyu.com/

你可能感兴趣的文章
poj 1976 A Mini Locomotive (dp 二维01背包)
查看>>
MODULE_DEVICE_TABLE的理解
查看>>
db db2_monitorTool IBM Rational Performace Tester
查看>>
postgresql监控工具pgstatspack的安装及使用
查看>>
【JAVA数据结构】双向链表
查看>>
【JAVA数据结构】先进先出队列
查看>>
乘法逆元
查看>>
Objective-C 基础入门(一)
查看>>
Flutter Boost的router管理
查看>>
iOS开发支付集成之微信支付
查看>>
C++模板
查看>>
【C#】如何实现一个迭代器
查看>>
【C#】利用Conditional属性完成编译忽略
查看>>
DirectX11 点光
查看>>
DirectX11 光照演示示例Demo
查看>>
VUe+webpack构建单页router应用(一)
查看>>
Node.js-模块和包
查看>>
JavaScript实现页面无刷新让时间走动
查看>>
前端设计之特效表单
查看>>
Java的时间操作玩法实例若干
查看>>