全局设置,对Tomcat下所有应用生效server.xml中添加下面一行,重启服务器即可:<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.*" deny=""/>
此行放在之前。例:
(1)只允许192.168.1.10,192.168.1.30访问:
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.10,192.168.1.30" deny=""/>
(2)只允许192.168.1.*网段访问:
<Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="192.168.1.*" deny=""/>
(3)禁止192.168.1.10、192.168.1.30访问:
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="192.168.1.10,192.168.1.30"/>
(4)根据主机名进行限制:
<Valve className="org.apache.catalina.valves.RemoteHostValve" allow="abc.com" deny=""/>