- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试阻止所有 IP 地址的特定 URL 页面 (http://www.testdomain.com/login),内部管理员 IP 地址除外。我没有阻止模式 login 的问题,但我想在本地测试以确保内部管理员 IP 被排除在/login url 的阻止规则之外。看看我到目前为止的...
<rewrite>
<rules>
<rule name="RequestBlockingRule1" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*login*" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{HTTP_X_Forwarded_For}" pattern="92.102.130.65" />
</conditions>
<action type="None" />
</rule>
<rule name="RequestBlockingRule2" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{URL}" pattern="*login*" />
</conditions>
<action type="CustomResponse" statusCode="404" statusReason="File or directory not found." statusDescription="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." />
</rule>
我还想要复制相同的规则,但查询字符串为 http://www.testdomain.com/home.aspx ?ctl=login
<rule name="RequestBlockingRule3" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*ctl=login*" negate="false" />
<conditions logicalGrouping="MatchAny" trackAllCaptures="true">
<add input="{HTTP_X_Forwarded_For}" pattern="93.107.170.85" />
</conditions>
<action type="None" />
</rule>
<rule name="RequestBlockingRule4" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions>
<add input="{QUERY_STRING}" pattern="*ctl=login*" />
</conditions>
<action type="CustomResponse" statusCode="404" statusReason="File or directory not found." statusDescription="The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." />
</rule>
</rules>
</rewrite>
我所做的是尝试排除特定模式的内部 IP,然后遵循实际的阻止规则。有谁知道a)更好的选择或b)看看我可能做错或可能不会做错(理想情况下,我想在使用真实IP地址的实际服务器上使用它们之前在本地测试这些规则)。谢谢
最佳答案
我想建议使用一些不同的方式:
<action type="None" />
配置代码为:
<rewrite>
<rules>
<rule name="Block login page" stopProcessing="true">
<match url="^login$" />
<conditions>
<add input="{Authorised Admin IPs:{REMOTE_ADDR}}" pattern="1" negate="true" />
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
<rule name="Block query string" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{Authorised Admin IPs:{REMOTE_ADDR}}" pattern="1" negate="true" />
<add input="{QUERY_STRING}" pattern="ctl=login" />
</conditions>
<action type="CustomResponse" statusCode="403" statusReason="Forbidden" statusDescription="Forbidden" />
</rule>
</rules>
<rewriteMaps>
<!-- This is your list of white-listed IP's-->
<rewriteMap name="Authorised Admin IPs">
<add key="92.102.130.65" value="1" />
<add key="93.107.170.85" value="1" />
<!-- local IPs-->
<add key="127.0.0.1" value="1" />
<add key="localhost" value="1" />
<add key="::1" value="1" />
</rewriteMap>
</rewriteMaps>
</rewrite>
此规则正在阻止所有具有非白名单 IP 的用户对该 URL 的所有请求
ctl=login
在查询字符串中在我上面的配置中,我使用的是 {REMOTE_ADDR}
.但您可能需要使用 {HTTP_X_Forwarded_For}
.这取决于您的网络基础设施(如果您有代理或负载平衡器)
您可以通过添加/删除本地 IP 表单重写映射在本地测试此规则
关于信息系统 |阻止特定于特定内部 IP 地址的页面特定 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44671155/
我在 Windows 10 的 IIS(版本 10.0.16299)中托管了一个站点。我的网站需要在 SSL 下运行。当我的网站需要使用 SSL 运行时,我收到错误403 - 禁止:访问被拒绝。 但是
我正在尝试阻止所有 IP 地址的特定 URL 页面 (http://www.testdomain.com/login),内部管理员 IP 地址除外。我没有阻止模式 login 的问题,但我想在本地测试
我有 2 台服务器(Web 和 APP 服务器)。 我已经在 APP 服务器上托管了我的 API,APP 服务器是由 ARR 使用反向代理从 Web 服务器访问的。 在调用 API 后 2 分钟准确显
CREATE TABLE updater ( nzp_up SERIAL PRIMARY KEY, version VARCHAR(50), status INT,
我已经运行 IIS 一个月了,刚刚发现文件 php52_errors.log 已经有 19 GB 大了。如何禁用这些日志? 最佳答案 您需要编辑 php.ini 文件 运行这个 php 脚本 并查找
我是一名优秀的程序员,十分优秀!