Tomcat限制IP访问

By | 2022年4月26日

tomcat可以拒绝指定IP访问web应用,具体配置参照如下:
/tomcat/conf/server.xml

<Host name="localhost"  appBase="webapps"
        unpackWARs="true" autoDeploy="true">

    <!-- SingleSignOn valve, share authentication between web applications
         Documentation at: /docs/config/valve.html -->
    <!--
    <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
    -->

    <!-- Access log processes all example.
         Documentation at: /docs/config/valve.html
         Note: The pattern used is equivalent to using pattern="common" -->
    <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
           prefix="localhost_access_log." suffix=".txt"
           pattern="%h %l %u %t &quot;%r&quot; %s %b" />

    <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.246.49"/>
    <Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.246.50"/>
</Host>

上述配置限制了IP192.168.246.49和192.168.246.50对该web应用的访问。

Category: 未分类 标签:

发表评论

您的电子邮箱地址不会被公开。