【问题标题】:Tomcat 8 RemoteHostValve not workingTomcat 8 RemoteHostValve 不工作
【发布时间】:2017-07-23 10:54:46
【问题描述】:

对我的服务器的访问应该仅限于某些远程主机,并且我想允许 Uptimerobot 监控我的服务器。

目前 uptimerobot 总是被 403 禁止。

我添加的 Server.xml 看起来是这样的:

<Server .........>
  <Service name="Catalina">
      <Engine>
        <Value className="org.apache.catalina.valves.RemoteHostValve" allow=".*\.uptimerobot\.com" />
      </Engine>
  </Service>

匹配此列表中的所有主机UptimeRobot Whitelist

但重启服务器后没有任何变化,仍然是 403。

我也尝试过使用不带通配符的域名,如下所示:

allow="engine19\.uptimerobot\.com"
allow="engine19.uptimerobot.com"

但还是 403,

我尝试通过添加来启用主机名查找

enableLookups="true"

&lt;Connector 标记,但同样没有效果。

但在我的日志中,我看到访问被解析为“engine19.uptimerobot.com”,这与我的 RemoteHost-Pattern 匹配。

任何想法,为什么它仍然被禁止?

编辑:

通过IP访问

 <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="63\.143\.42\.244"/>

正在工作。但我不想在那里添加整个 ips 列表。 RemoteAddrValveRemoteHostValve会不会互相打扰?

【问题讨论】:

  • 你能告诉我你是如何解决这个问题的吗?因为我面临同样的问题。
  • Unfurtunally 我还没有找到任何解决这个问题的方法:(

标签: tomcat8 remote-host


【解决方案1】:

我试过了,这对我有用

在连接器中将 useIPVHosts 设置为 true(在 server.xml 中)。

我正在使用 HTTP 连接器,它看起来如下

<Connector port="8080" protocol="HTTP/1.1"
    connectionTimeout="20000"
    redirectPort="8443"
    enableLookups="true"
    useIPVHosts="true" />

Details of attributes can be found here

【讨论】:

    【解决方案2】:

    检查 tomcat/logs/local_access_log... 查看 403 使用的主机名。

    我发现我们公司的 DNS 报告了一些全大写和全小写的名称。使用 (?i) 使正则表达式不区分大小写:

    allow="(?i)engine19\.uptimerobot\.com"
    

    如果您同时拥有 RemoteHostValve 和 RemoteAddValve,则两者都必须允许传入主机。如果其中一个不允许,则返回 403。

    【讨论】:

    • 但是如果我尝试根据域模式允许任何主机,我不喜欢添加每个 IP 地址。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-09-08
    • 1970-01-01
    • 2014-05-08
    • 1970-01-01
    • 1970-01-01
    • 2018-10-09
    相关资源
    最近更新 更多