apache、iis6、ii7獨立ip主機屏蔽限制ip訪問(適用vps云主機)注: Linux下 規(guī)則文件.htaccess(手工創(chuàng)建.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下 規(guī)則文件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及以上版本 規(guī)則文件web.config (手工創(chuàng)建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寶塔面板設(shè)置屏蔽IP規(guī)則,可以在寶塔面板-》對應(yīng)站點偽靜態(tài)處設(shè)置: 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;}
|
|||||
| >> 相關(guān)文章 | |||||
|
|
|||||