Oracle Service Bus 11g - 如何配置以获取请求的X-Forwarded-For标头

时间:2016-04-29 10:05:17

标签: apache jmx weblogic11g osb

我们最近在我们的域中配置了Apache Load Balancers,通过它可以平衡HTTP请求并将其传递给各种OSB Web服务。 Apache LB配置有ProxyPreserveHost On,执行将客户端的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>

{@ 1}} | client-host值是Apache LB的值,我们期望客户端的源IP地址显示在用户标题中的client-address下 - 如下所示:

trans:headers

我已阅读此链接:http://www.javamonamour.org/2014/07/osb-and-load-balancer-source-ip.html但我不确定我们究竟需要做什么。我已使用<tran:user-header name="X-Forwarded-For" value="yy.yy.yyy.yyy"/>连接到管理服务器,并从用户请求中找到jconsole的{​​{1}} X-​​Forwarded-For`标头?

1 个答案:

答案 0 :(得分:1)

除非明确设置,否则OSB不会解析传入的传输头。有一个选项&#39; Get All Headers&#39;在代理本身;启用该复选框将允许在代理内部访问它们。