0

我正在运行 TOMCAT 服务器。出于安全原因,我必须仅限制对 localhost 的访问,但必须从外部(任何 IP)访问一个应用程序。我尝试使用放置在 server.xml 中的阀门,但我只能阻止对特定功能/应用程序的访问,例如主机管理器。

如何限制除一个应用程序之外的所有应用程序?

编辑: server.xml 中的这一行会阻止除 localhost 之外的所有内容:

<Server>
<Service>
<Engine>
<Host>

...

<Valve className="org.apache.catalina.valves.RemoteAddrValve" 
allow="127\.\d+\.\d+\.\d+|::1|0:0:0:0:0:0:0:1"/>

</Host>
</Engine>
</Service>
</Server>

如何为一个必须从外部访问的应用程序添加例外?

提前感谢您的帮助:-)

4

1 回答 1

0

您需要 2 个目录来存储不同的 webapps,并且最小配置如下所示,其中 serverhost 是您网络上已知的服务器名称:

<Service name="internal">
  <Connector port="8081" protocol="HTTP/1.1" address="localhost" />
  <Engine name="Engine1internal" defaultHost="localhost">
    <Host name="localhost" appBase="webapps1"></Host>
  </Engine>
</Service>

<Service name="exposed">
  <Connector port="8080" protocol="HTTP/1.1" address="192.168.1.2"/>
  <Engine name="Engine2exposed" defaultHost="serverhost">
    <Host name="serverhost" appBase="webapps2"></Host>
  </Engine>
</Service>

当然,如果您想保留 webapps 目录,只需创建一个目录来存储另一个应用程序。我没有测试但改编自另一个配置,因此如有必要,请随时评论/编辑我的答案。

于 2019-06-28T11:41:06.527 回答