IIS7 web.config 重写以限制 IP 范围的访问 - 无法使其工作?
我只是在我们公司网站的现有重写规则上添加一组规则。我们有一个文件需要限制为仅允许我们的内部 IP 地址。网址为 http://oursite.com/internal/index.aspx?u=blahblah< /a> 并需要将其限制为 IP 范围 10.1.XX 我添加了此内容,但它没有执行任何操作。即使我尝试捕获所有使用 .* 作为模式的内容,它仍然会忽略它。我的语法正确吗?谢谢。
<rewrite>
<rules>
...
<rule name="Restrict URL" enabled="true" stopProcessing="true">
<match url="internal/index\.aspx" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="^10\.1\.\d+\.\d+$" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
I'm simply adding to a set of rules on existing rewrite rules for our company website. We have a file that we need to restrict to only our internal IP addresses. The URL is http://oursite.com/internal/index.aspx?u=blahblah and need it restricted to IP ranges 10.1.X.X. I'm adding this and it's not doing anything. Even if I tried to capture all using .* for the pattern, it still ignores it. Is my syntax correct? Thanks.
<rewrite>
<rules>
...
<rule name="Restrict URL" enabled="true" stopProcessing="true">
<match url="internal/index\.aspx" />
<conditions>
<add input="{REMOTE_ADDR}" pattern="^10\.1\.\d+\.\d+$" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
</rules>
</rewrite>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了这个问题。由于我们的托管提供商的原因,我最终使用 HTTP_X_FORWARDED_FOR 作为标头。
I resolved this myself. I ended up using HTTP_X_FORWARDED_FOR as the header, due to our hosting provider.