如需要屏蔽ip:7.7.7.7和8.8.8.8
Linux下 規(guī)則文件.htaccess(手工創(chuàng)建.htaccess文件到站點(diǎn)根目錄)
<IfModule mod_rewrite.c>
RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR}&%{http:X-Real-IP} (7.7.7.7|8.8.8.) [NC]
RewriteRule (.*) - [F]
</IfModule>
windows2008下 規(guī)則文件web.config (手工創(chuàng)建web.config文件到站點(diǎn)根目錄)
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="band ip" stopProcessing="true">
<match url="(.*)" />
<conditions logicalGrouping="MatchAny">
<add input="%{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR}&%{HTTP_X_Real_IP}" pattern="(7.7.|8.8.8.8)" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
java主機(jī)屏蔽IP或IP段
在tomcat管理-》編輯server.xml
找到 <Host></Host>
在節(jié)點(diǎn)中配置
<Valve className="org.apache.catalina.valves.RemoteAddrValve" deny="7.7.7.7|8.8.8.*"/>
屏蔽后重啟tomcat生效,訪問提示403