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 "%r" %s %b" /> <!-- 限制指定IP地址访问Tomcat --> <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="172.16.2.37" deny=""/> </Host>