我试图阻止一系列发送大量垃圾邮件的IP到我的博客。 我不能使用这里描述的解决scheme,因为这是一个共享主机,我不能改变任何东西到服务器configuration。 我只能访问远程IIS中的几个选项。
我看到URL重写模块有一个选项来阻止请求,所以我试图使用它。 我的规则如下web.config :
<rule name="BlockSpam" enabled="true" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll" trackAllCaptures="false"> <add input="{REMOTE_ADDR}" pattern="10\.0\.146\.23[0-9]" ignoreCase="false" /> </conditions> <action type="CustomResponse" statusCode="403" /> </rule>
不幸的是,如果我把它放在重写规则的末尾,它似乎不会阻塞任何东西……如果我把它放在列表的开头,它会阻止一切! 看起来这个条件没有考虑到。
在UI中, stopProcessing选项不可见,默认情况下为true 。 在web.config中将其更改为false似乎没有任何作用。
我不知道现在该做什么…有什么想法?
#1 WP插件
WordPress的,看看下面,你可能会或可能不需要一个插件
既然你有控制networking服务器,安装插件应该没有问题。
#2 IIS Web.config
可以使用IIS Web.config完成IP基础阻塞,下面是允许所有但阻止特定IP的示例
<security> <ipSecurity allowUnlisted="true"> <!-- this line allows everybody, except those listed below --> <clear/> <!-- removes all upstream restrictions --> <add ipAddress="83.116.19.53"/> <!-- blocks the specific IP of 83.116.19.53 --> <add ipAddress="83.116.119.0" subnetMask="255.255.255.0"/> <!--blocks network 83.116.119.0 to 83.116.119.255--> <add ipAddress="83.116.0.0" subnetMask="255.255.0.0"/> <!--blocks network 83.116.0.0 to 83.116.255.255--> <add ipAddress="83.0.0.0" subnetMask="255.0.0.0"/> <!--blocks entire /8 network of 83.0.0.0 to 83.255.255.255--> </ipSecurity> </security>
更多信息在这个链接 。
#3 IIS Web.config重写
在这里find,也许你可以试试。
<!-- Heading for the XML File --> <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <!-- This is where the rules start, this one will block EVERYTHING on your site with the <match url=".*" /> --> <rules> <rule name="Blocked Users" stopProcessing="true"> <match url=".*" /> <conditions> <!-- This will just go to the 'Bad Ips' rewriteMap below and compare it to the REMOTE_ADDR which is the requesting IP --> <add input="{Bad Ips:{REMOTE_ADDR}}" pattern="1" /> </conditions> <!-- Actions can be Custom Rewrite, Redirect, or Just Abort Request, uncomment examples as needed --> <action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" /> <!-- This one will rewrite url to specified file <action type="Rewrite" url="error.html" appendQueryString="false" /> --> <!-- This on will redirect to another site <action type="Redirect" url="http://www.google.com" appendQueryString="false" /> --> <!-- This one will just Abort <action type="AbortRequest" /> --> </rule> </rules> <!-- This rewrite Map is where you choose your blocked IP's, values with 1 are blocked, all others are ignored, simple add your keys --> <rewriteMaps> <rewriteMap name="Bad Ips"> <!-- This one will use wildcards --> <add key="108.166.*.*" value="1" /> <!-- This one wil use static IP --> <add key="12.13.15.16" value="1" /> </rewriteMap> </rewriteMaps> </rewrite> </system.webServer> </configuration>