Apache Oracle服务总线11g-如何配置以获取请求';s X-Forwarded-For报头
我们最近在我们的域中配置了Apache负载平衡器,通过它可以平衡HTTP请求并将其传递给各种OSB Web服务。Apache LBs在上配置了Apache Oracle服务总线11g-如何配置以获取请求';s X-Forwarded-For报头,apache,jmx,weblogic11g,osb,Apache,Jmx,Weblogic11g,Osb,我们最近在我们的域中配置了Apache负载平衡器,通过它可以平衡HTTP请求并将其传递给各种OSB Web服务。Apache LBs在上配置了ProxyPreserveHost,它执行将客户端IP地址写入新头X-Forwarded-For的任务 然后,我们的OSB Web服务尝试根据客户端的IP地址及其提供的用户名/密码对客户端请求进行身份验证。问题是,当OSB流接收到一个新的请求时,X-Forwarded-For头不见了!启用跟踪后,请求看起来如下所示: <con:transport&
ProxyPreserveHost,它执行将客户端IP地址写入新头X-Forwarded-For
的任务
然后,我们的OSB Web服务尝试根据客户端的IP地址及其提供的用户名/密码对客户端请求进行身份验证。问题是,当OSB流接收到一个新的请求时,X-Forwarded-For
头不见了!启用跟踪后,请求看起来如下所示:
<con:transport>
<con:uri>/ws/service/interface</con:uri>
<con:mode>request-response</con:mode>
<con:qualityOfService>best-effort</con:qualityOfService>
<con:request xsi:type="http:HttpRequestMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
<http:Accept-Encoding>gzip,deflate</http:Accept-Encoding>
<http:Connection>Keep-Alive</http:Connection>
<http:Content-Length>1285</http:Content-Length>
<http:Content-Type>text/xml;charset=UTF-8</http:Content-Type>
<http:Host>www.a.service.com</http:Host>
<http:SOAPAction>""</http:SOAPAction>
<http:User-Agent>Apache-HttpClient/4.1.1 (java 1.5)</http:User-Agent>
</tran:headers>
<tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">UTF-8</tran:encoding>
<http:client-host>www.a.service.com</http:client-host>
<http:client-address>xx.xxx.x.xxx</http:client-address>
<http:http-method>POST</http:http-method>
</con:request>
<con:response xsi:type="http:HttpResponseMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tran:headers xsi:type="http:HttpResponseHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
<http:Content-Type>text/xml</http:Content-Type>
</tran:headers>
<tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
</con:response>
</con:transport>
/ws/service/interface
请求-响应
尽力
gzip,放气
活命
1285
text/xml;字符集=UTF-8
www.a.service.com
""
Apache HttpClient/4.1.1(java 1.5)
UTF-8
www.a.service.com
xx.xxx.x.xxx
邮递
文本/xml
0
客户机主机
|客户机地址
值是Apache LB的值,我们希望客户机的源IP地址出现在用户标题中的trans:headers
下-如下所示:
<con:transport>
<con:uri>/ws/service/interface</con:uri>
<con:mode>request-response</con:mode>
<con:qualityOfService>best-effort</con:qualityOfService>
<con:request xsi:type="http:HttpRequestMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tran:headers xsi:type="http:HttpRequestHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
<http:Accept-Encoding>gzip,deflate</http:Accept-Encoding>
<http:Connection>Keep-Alive</http:Connection>
<http:Content-Length>1285</http:Content-Length>
<http:Content-Type>text/xml;charset=UTF-8</http:Content-Type>
<http:Host>www.a.service.com</http:Host>
<http:SOAPAction>""</http:SOAPAction>
<http:User-Agent>Apache-HttpClient/4.1.1 (java 1.5)</http:User-Agent>
</tran:headers>
<tran:encoding xmlns:tran="http://www.bea.com/wli/sb/transports">UTF-8</tran:encoding>
<http:client-host>www.a.service.com</http:client-host>
<http:client-address>xx.xxx.x.xxx</http:client-address>
<http:http-method>POST</http:http-method>
</con:request>
<con:response xsi:type="http:HttpResponseMetaData" xmlns:http="http://www.bea.com/wli/sb/transports/http" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<tran:headers xsi:type="http:HttpResponseHeaders" xmlns:tran="http://www.bea.com/wli/sb/transports">
<http:Content-Type>text/xml</http:Content-Type>
</tran:headers>
<tran:response-code xmlns:tran="http://www.bea.com/wli/sb/transports">0</tran:response-code>
</con:response>
</con:transport>
我读过这个链接:但我不确定我们到底需要做什么。我已使用jconsole
连接到管理服务器,并找到了WebServerMBean
的ClientIpHeader'(当前为空),但它是只读的,没有设置器。你知道我需要在Weblogic OSB中做什么才能从用户请求中检索
X-Forwarded-For`header吗?除非明确设置,否则OSB不会解析传入的传输头。在代理本身上有一个选项“获取所有标题”;启用该复选框将允许在代理内部访问它们。您是否使用curl
或soapui
进行了测试,手动传入头并检查OSB是否可以看到它?@TrentBartlem,我尝试了您的建议,但添加的头仍然没有出现在OSB流的跟踪日志中。在我的测试中,我创建了一个新的Soap UI请求,并添加了一个值为“192.168.1.1”的头'X-Forwarded-For'
,但在将请求直接发送到相关OSB Web服务后,它没有显示在OSB的跟踪日志中。您是否在代理上设置了获取所有头
在代理服务上解决了这个问题。我们现在可以看到“X-Forwarded-For”标题了。请提交您的建议作为问题的答案,以便我可以接受并结束。