apache、iis、nginx拦截屏蔽ip

admin 2019-08-12 PM 313℃ 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}&amp;%{REMOTE_ADDR}&amp;%{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;
标签: nginx, apache, iis, 屏蔽

非特殊说明,本博所有文章均为博主原创。