【问题标题】:Is there a way to tell from the HttpServletRequest if a request is via a Apache AJP connector or direct有没有办法从 HttpServletRequest 判断请求是通过 Apache AJP 连接器还是直接
【发布时间】:2021-02-04 21:33:02
【问题描述】:

有没有办法从 HttpServletRequest 中判断请求是通过 Apache AJP 连接器还是直接发出的

   <Connector port="8443"
               scheme="https" secure="true" enableLookups="false" disableUploadTimeout="true"
               maxHttpHeaderSize="8192" maxThreads="8000" acceptCount="3000" SSLEnabled="true"
               maxConnections="10000" protocol="org.apache.coyote.http11.Http11NioProtocol">
             ...
    </Connector>

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" secretRequired="false" />

我们的场景是一些用户通过互联网访问tomcat

webaddress:8443 --> 防火墙指向 Intranet apache:443 --> AJP 连接器到 tomcat:8009

在 Intranet 上时,客户管理员已将网址映射到 tomcat,以便

网址:8443 --> tomcat:8443

所以浏览器 URL 是相同的网址:8443 所以从 URL 无法判断它是通过 apache 还是直接到 tomcat

【问题讨论】:

    标签: servlets tomcat9


    【解决方案1】:

    通过在apache中设置header找到了一种方法

    RequestHeader 设置 PROXY_HEADER APACHE

    然后检测 HttpServletRequest.getHeaders 中的 PROXY_HEADER

    【讨论】:

      猜你喜欢
      • 2017-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      相关资源
      最近更新 更多