云服务器限制ip访问的设置方法(apache、iis6、ii7)
Linux
规则文件.htaccess(手工创建.htaccess文件到站点根目录)
规则文件.htaccess(手工创建.htaccess文件到站点根目录)
<IfModule mod_rewrite.c>
RewriteEngine On
#Block ip
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
</IfModule>
windows2003
规则文件httpd.conf
规则文件httpd.conf
若是安装了我司助手环境请先按http://faq.myhostadmin.net/faq/listagent.asp?unid=650 把伪静态组件开启,然后添加以下规则。
若是纯净版系统,请按http://faq.myhostadmin.net/faq/listagent.asp?unid=639 把伪静态组件开启,然后在配置文件中按以下系统规则配置
#Block ip
RewriteCond %{HTTP_X_FORWARDED_FOR}&%{REMOTE_ADDR} (8.8.4.4|8.8.8.) [NC]
RewriteRule (.*) - [F]
windows2008
规则文件web.config (手工创建web.config文件到站点根目录)
规则文件web.config (手工创建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}" pattern="(8.8.4.4|8.8.8.)" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
注:根据需求修改(8.8.4.4|8.8.8.)ip范围
比如
1,要屏蔽的ip范围是 188.143.232.*
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (188.143.232.) [NC]
2,要屏蔽的单个ip是 188.143.232.23
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (188.143.232.23) [NC]
3,,要屏蔽的ip范围是 188.143.*.*
RewriteCond %{http:X-Forwarded-For}&%{REMOTE_ADDR} (188.143.) [NC]
相关问题
下载此文章 (欢迎转载,请注明出处:http://www.xmxwl.net/help/member/20160311/13644.html)