Squid的URL修改/重写
我需要修改一些通过Squid传递的特殊URL,例如:我通过我的Squid访问地址www.google.com.vn。我想在某些地方修改 Squid 源代码,将 www.google.com.vn 替换为 www.google.com。所以每个对 www.google.com.vn 的请求都会变成对 www.google.com 的请求
请帮助 ASPS
I need to modify some special URLs which are passed over Squid, for example: i access the address www.google.com.vn through out my Squid. I want to modify Squid source code at some where to replace www.google.com.vn into www.google.com. So every requests to www.google.com.vn will become requests to www.google.com
Please help ASPS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,squid 重写和重定向依赖于第三方助手。
最好的部分是您可以使用任何编程语言编写此帮助程序。
在squid.conf中使用
url_rewrite_program
指令并向其中添加自定义脚本的路径。
您的脚本将收到以下内容:
URL client_ip "/" fqdn user method [ kvpairs]\n
显然您需要
URL
部分,因此想办法获取url 部分并返回您希望客户端定向到的网站。希望以任何方式提供帮助...
重写程序示例(C++)
First of all, squid rewriting and redirecting depends on a third party helper.
The best part is that you can write this helper in any programming language.
use the
url_rewrite_program
directive in squid.confand add to it the path to your custom made script.
Your script will receive content with the following:
URL client_ip "/" fqdn user method [ kvpairs]\n
Obviously you need the
URL
part,so figure a way to get the url part and return the website you want the client to be directed to.Hope that help in any way...
Example rewrite programm (C++)