apache、iis、nginx拦截屏蔽ip
admin
2019-08-12 PM
500℃
0条
apache
<IfModule mod_rewrite.c>
RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR}&%{http:X-Real-IP} ^(8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
</IfModule>
iis
ii6通过isapi重写组件
#Block ip
RewriteCond %{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR}&%{HTTP_X_Real_IP} ^(8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
iis7以上web.config
<?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="^(8.8.4.4|8.8.8.)" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
nginx
添加到配置文件server段内
#屏蔽192.168.5.23这个IP
deny 192.168.5.23;
#屏蔽192.168.5.* 这个段
deny 192.168.5.0/24;