Apache:用于阻止 URL 的 .htaccess 与 vhost conf 文件
我需要阻止一些在我的 Web 服务器 (Apache) 中产生大量流量的 uld URL。例如,阻止所有请求,例如 https://example.com/xxxxxx/
我做不到与 IPtables 一起使用,所以我在我的 . htaccess
即仍然消耗大量资源,我想知道是否有更好的方法在到达 Apache 之前阻止请求。或者在 Apache 中执行此操作的另一种最有效的方法。例如,我听说解析 .htaccess 文件会消耗资源,因此不确定使用 vhost .conf 文件是否有帮助,或者它实际上是相同的...
有关如何阻止使用 URL 的请求有什么建议吗?
谢谢各位专家!
I need to block some uld URLs that are generating a lot of traffic in my web server (Apache). For example to block all the requests like https://example.com/xxxxxx/
I Can't do that with IPtables so I am using mod_rewrite with a rule in my .htaccess
That is still consuming a lot of resources and I am wondering if there is a better way to block the request before reaching Apache. Or another most efficient way to do it within Apache. For example, I heard that parsing .htaccess files consumes resources so not sure if using the vhost .conf file can help or it is really the same...
Any advice on how can I block requests using the URL?
Thank you experts!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当然,分布式配置文件比单个集中静态配置消耗更多负载。但区别并不像白天和黑夜。分布式配置的问题更多的是保持概览和维护概览的工作量。
如果你可以让这些请求远离 http 服务器,你肯定会看到更多的不同。您可以考虑使用前端服务器。像 nginx 或 HAProxy 这样的东西充当看门人,只转发那些你真正想要响应的请求。但这在单个系统上没有什么意义,您需要两个单独的云服务甚至系统。
Certainly distributed configuration files consume more load than a single, central and static configuration. But the differences are not like day and night. The issue with a distributed configuration is more the effort to keep the overview, to maintain it.
If you can keep those requests away from the http server at all you certainly will see more difference. You could consider using a frontend server. Something like nginx or HAProxy that acts as a gate keeper and only forwards those requests you actually want to respond to. This makes little sense on a single system though, you'd need two separate cloud services or even systems for that.
最好的方法是将这样的内容添加到您的 httpd / vhost.conf 文件中:
每次调用 /xxxx 都会导致 mod_rewrite 返回 403 响应。
确保将这些规则放入相应的虚拟主机标记中。
The best approach would be to add something like this to your httpd / vhost.conf file:
Every call to /xxxx would result in mod_rewrite to return a 403 response.
Make sure to place those rules into the according vhost tag.