Tomcat 限制IP请求后端接口

Tomcat 限制只允许的IP请求后端接口

配置 server.xml ; 添加 org.apache.catalina.valves.RemoteAddrValve 规则配置。

<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" />
    
    <!-- 限制指定IP地址访问Tomcat -->
    <Valve className="org.apache.catalina.valves.RemoteAddrValve"
           allow="172.16.2.37"
           deny=""/>
</Host>
posted @ 2019-12-31 15:56  01234567  阅读(499)  评论(0编辑  收藏  举报