如何进行 Squid-Cache 内部 URL 重写?

发布于 2024-11-18 13:31:24 字数 569 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼痛 2024-11-25 13:31:24

您是否尝试将鱿鱼设置为“accel”模式的反向代理?它对我有用:

acl all src all

http_port 3128 accel vhost
cache_peer 127.0.0.1 parent 80 0 no-query originserver name=myAccel
acl our_sites dstdomain your_domain.net
http_access allow our_sites
http_access deny all
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all
negative_ttl 0

access_log /var/log/squid/access.log squid
hosts_file /etc/hosts
coredump_dir /var/spool/squid

your_domain.net 是您要重定向的域

Did you try setting squid as a reverse proxy with the 'accel' mode ? It worked for me:

acl all src all

http_port 3128 accel vhost
cache_peer 127.0.0.1 parent 80 0 no-query originserver name=myAccel
acl our_sites dstdomain your_domain.net
http_access allow our_sites
http_access deny all
cache_peer_access myAccel allow our_sites
cache_peer_access myAccel deny all
negative_ttl 0

access_log /var/log/squid/access.log squid
hosts_file /etc/hosts
coredump_dir /var/spool/squid

your_domain.net is the domain you want to redirect

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文