Tomcat 鎖 IP
2013-12-15 01:41
修改context.xml
<Context>
<WatchedResource>WEB-INF/web.xml</WatchedResource>
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny= "xxx.xxx.xxx.xxx"/>
</Context>
xxx.xxx.xxx.xxx為要封鎖的IP
deny可修改為allow,則變成只允許xxx.xxx.xxx.xxx瀏覽的IP
重新啟動Tomcat,則會出現http code: 403
修改web.xml,並增加403.html來顯示拒絕頁面
<error-page>
<error-code>403</error-code>
<location>/403.html</location>
</error-page>