apache、iis6、ii7獨立ip主機屏蔽限制ip訪問(適用vps雲主機)
發佈時間:2014-12-25
注:
如果只屏蔽IP 8.8.4.4 則寫(8.8.4.4)
如果只屏蔽IP段8.8.8.* 則寫(8.8.8\.)
屏蔽多段中間用|隔開,如(8.8.4.4|8.8.8\.)
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
若是安裝了我司助手環境請先按http://www.west.cn/faq/list.asp?unid=650 把偽靜態組件開啓,然後添加以下規則。
若是純淨版系統,請按http://www.west.cn/faq/list.asp?unid=639 把偽靜態組件開啓,然後在配置文件中按以下系統規則配置
#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;}
