将 IP 地址列入黑名单
<?php if($_SERVER['REMOTE_ADDR'] != 'xx.xx.xx.xx') {
header("Location: http://google.com");
} ?>
这是阻止某些 IP 地址访问 Windows 服务器上某些文件夹的好方法吗?
或者可以使用像 webscarab 这样的代理软件来拦截它,并且可以修改原始 IP 地址来绕过这个?
<?php if($_SERVER['REMOTE_ADDR'] != 'xx.xx.xx.xx') {
header("Location: http://google.com");
} ?>
Is this a good way to block certain IP addresses from accessing some folders on my windows server ?
Or it can be intercepted with proxy softwares like webscarab and the originating IP address could be modified to bypass this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
任何具有与您阻止的 IP 地址不同的代理都可以绕过它。你可以检查
X-Forwarded-For
(使用apache_request_headers()
如果你使用的是Apache将其挖掘出来),但这更容易如果您将其优先于$_SERVER['REMOTE_ADDR']
,则为欺骗。另外,我可以忽略您的
Location
标头。在其后面也放置一个exit
。It can bypassed with any proxy with has a different IP address to the one you are blocking. You could check
X-Forwarded-For
(dig it out withapache_request_headers()
if you are using Apache), but this is much easier to spoof if you give it precedence over$_SERVER['REMOTE_ADDR']
.Also, I could ignore your
Location
header. Put anexit
after it as well.如果您只想通过 IP 进行阻止,您可以使用 .htaccess - 为一组目录设置规则更容易,而不是创建大量 php 文件。但这对于过滤器用户来说并不是一个好方法。创建一个简单的注册表单,或使用 Twitter、Facebook 或其他网站的 API。
If your are want only blocking by IP you can use .htaccess for that - it's more easy to set rule for set of directories instead of creating a lot of php files. But it's not a good method for filter users. Create a simple registration form, or use API from twitter, facebook or another.