【问题标题】:Configuring Liberty with httpProxyRedirect使用 http 代理重定向配置 Liberty
【发布时间】:2017-05-05 18:22:22
【问题描述】:

我正在尝试将不安全端口上的流量重定向到安全端口,如下所述: https://www.ibm.com/support/knowledgecenter/en/SSD28V_9.0.0/com.ibm.websphere.liberty.autogen.core.doc/ae/rwlp_config_httpProxyRedirect.html

相反,两个端口都可用,我在日志中看不到任何内容。就好像根本没有配置 httpProxyRedirect 一样。

<?xml version="1.0" encoding="UTF-8"?>
<server description="CAST Liberty Server">
    <!-- Enable features -->
    <featureManager>
        <feature>webProfile-7.0</feature>
    </featureManager>

    <application id="app" context-root="/" type="war" location="${war.name}">
        <classloader apiTypeVisibility="spec, ibm-api, api, third-party" />
    </application>

    <httpProxyRedirect id="defaultHttpProxyRedirect" httpPort="${http.port}" httpsPort="${https.port}" />

    <keyStore id="defaultKeyStore" password="pass" />
    <httpEndpoint host="*" httpPort="${http.port}" httpsPort="${https.port}" id="defaultHttpEndpoint" />

    <applicationMonitor updateTrigger="mbean" />
</server>

【问题讨论】:

    标签: websphere websphere-liberty http-redirect


    【解决方案1】:

    很可能,您缺少 web.xml 中的安全约束。此配置告诉服务器哪些 URL 需要通过安全传输访问,然后将符合条件的请求从非安全端口重定向到安全端口。本教程可能会有所帮助:https://docs.oracle.com/cd/E19798-01/821-1841/bncbk/index.html

    另外,请记住 server.xml 中的 httpProxyRedirect 配置用于在您的应用程序服务器前面有代理服务器时进行重定向。例如,您的代理服务器可能位于主“www.ibm.com”主机上 - 侦听 HTTP 端口 80 和 HTTPS 端口 443。但该主机可能会将一些请求路由到其他主机上的 Liberty 应用程序服务器(例如“ app1host.internal.ibm.com") 监听不同的端口(即 HTTP 端口 9080 和 HTTPS 端口 9443)。在这种情况下,仅使用 web.xml 中的安全约束将尝试将 Liberty 服务器上的客户端请求从 9080 重定向到 9443,但在 www.ibm.com 主机上 - 这些端口上没有任何内容正在侦听。在这种情况下,您应该像这样配置 httpProxyRedirect:

    <httpProxyRedirect httpPort="80" httpsPort="443" host="www.ibm.com" />
    

    通过配置,对安全 URL 的客户端 HTTP 请求将被重定向到端口 443 上的 www.ibm.com,代理服务器会将请求转发到 app1host.internal.ibm.com 端口 9443。

    希望这会有所帮助, 安迪

    【讨论】:

      【解决方案2】:

      这是我在 web.xml 中使用的安全约束,它适用于 Tomcat 和 IBM Websphere 8.5.5.15:

      <security-constraint>
          <web-resource-collection>
              <web-resource-name>Entire Application</web-resource-name>
              <url-pattern>/*</url-pattern>
          </web-resource-collection>
          <user-data-constraint>
              <transport-guarantee>CONFIDENTIAL</transport-guarantee>
          </user-data-constraint>
      </security-constraint>
      

      注意:确保将其放在 &lt;servlet-mapping&gt; 之后。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-09-30
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-03-08
        • 1970-01-01
        • 1970-01-01
        • 2016-12-28
        相关资源
        最近更新 更多