apache、iis6、ii7独立ip主机屏蔽限制ip访问(适用vps云主机)注: Linux下 规则文件.htaccess(手工创建.htaccess文件到站点根目录) <IfModule mod_rewrite.c> RewriteEngine On #Block ip RewriteCond %{http:X-Forwarded-For} ^(8.8.4.4|8.8.8\.) [OR] RewriteCond %{REMOTE_ADDR} ^(8.8.4.4|8.8.8\.) [OR] RewriteCond %{http:X-Real-IP} ^(8.8.4.4|8.8.8\.) [NC] RewriteRule (.*) - [F] </IfModule> windows2003下 规则文件httpd.conf
#Block ip RewriteCond %{http:X-Forwarded-For} ^(8.8.4.4|8.8.8\.) [OR] RewriteCond %{REMOTE_ADDR} ^(8.8.4.4|8.8.8\.) [OR] RewriteCond %{http:X-Real-IP} ^(8.8.4.4|8.8.8\.) [NC] RewriteRule (.*) - [F] windows平台IIS7及以上版本 规则文件web.config (手工创建web.config文件到站点根目录) <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="band ip"> <match url="(.*)" ignoreCase="false" /> <conditions logicalGrouping="MatchAny"> <add input="{HTTP_X_FORWARDED_FOR}" pattern="^(8.8.4.4|8.8.8\.)" ignoreCase="false" /> <add input="{REMOTE_ADDR}" pattern="^(8.8.4.4|8.8.8\.)" ignoreCase="false" /> <add input="{HTTP_X_REAL_IP}" pattern="^(8.8.4.4|8.8.8\.)" ignoreCase="false" /> </conditions> <action type="AbortRequest" /> </rule> </rules> </rewrite> </system.webServer> </configuration> nginx宝塔面板设置屏蔽IP规则,可以在宝塔面板-》对应站点伪静态处设置: if ( $http_x_forwarded_for ~* '8.8.8.8|114.114.114.114') {return 444;} if ( $remote_addr ~* '8.8.8.8|114.114.114.114') {return 444;} if ( $http_x_real_ip ~* '8.8.8.8|114.114.114.114') {return 444;}
|
|||||
>> 相关文章 | |||||
© 2024 365.hk 版权所有,保留所有权利