如何进行 Squid-Cache 内部 URL 重写?
squid-cache 的 url_rewrite_program 确实重定向了 URL。换句话说,最终用户收到的响应是“从 foo 到 bar 的重定向页面”,然后用户向重定向地址发出另一个请求。我不想要这个。
我想要实现的功能类似于apache的mod_rewrite。我想要一个绝对透明的重写机制。这样用户请求特定内容,并且他将其作为响应获取(无论他最初请求的 URL 是什么),而无需任何 HTTP 重定向。
我想避免通过 http 重定向的原因是因为我不希望最终用户看到内部应用程序结构。例如,他请求“application1.foo.com”,并且他获得了更长的 URL 内容。因此,如果最终用户为其添加书签,他就会为我干净的小 URL(application1.foo.com”添加书签,这有助于让用户远离此类详细信息,即使我在其中更改它,它最终也会为他们提供统一的服务 URL例如,我可能最初将 application1.foo.com 映射到 badprovider.com/path/to/file.php,然后将其更改为 goodprovider.com/file.php,用户不会注意到这一点。优点是,例如,最终用户书签将保持正确,并以更具指导性的方式规范他们的行为。
url_rewrite_program by squid-cache really redirects the URL. In other words, the end-user gets a response back that says "redirectted page from foo to bar", and then the user makes another request to the redirected address. I don't want this.
what I want to achieve is similar to apache's mod_rewrite. I want an abselutely transparent rewriting mechanism. So that the user requests for a spefific content, and he gets it as a response (regardless of his initial requested URL) without any HTTP redirection.
the reason I want to avoid redirection via http is because I don't want the end-user to see internal application structures. For example, he requests "application1.foo.com", and he gets content of a URL that's much lengthier. So if the end-user bookmarks it, he bookmarks my clean little URL (application1.foo.com", this is good to keep users away from such details, it eventually gives them a uniform URL for the service even if I change it in the future. For example, I might map application1.foo.com to badprovider.com/path/to/file.php initially, and then change it to goodprovider.com/file.php and the user won't notice that. The advantage is, for example, end-user bookmarks would remain correct, as well as regulating their behaviour in a more guided manner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否尝试将鱿鱼设置为“accel”模式的反向代理?它对我有用:
your_domain.net 是您要重定向的域
Did you try setting squid as a reverse proxy with the 'accel' mode ? It worked for me:
your_domain.net is the domain you want to redirect