【问题标题】:Change the url of the backend but not the client one using Varnish使用 Varnish 更改后端的 url 但不是客户端的 url
【发布时间】:2013-01-30 11:51:21
【问题描述】:

我想将客户端网址“www.example.com/download..”操作为“one.other.com/download... 但我希望客户端上的 url 保持第一个“www.example.com/download”

Varnish 3 有什么方法可以做到这一点吗??

【问题讨论】:

    标签: url varnish varnish-vcl


    【解决方案1】:

    是的,您可以使用vcl_recv 中的VCL 中的regsub() 函数轻松完成。

    例如:

    if (req.http.host ~ "^(www\.)?example\.com" && req.url~ "^/download/") {
      set req.http.host = "one.other.com";
      set req.url = regsub(req.url, "^/download/", "/");
    } 
    

    此示例将对http://www.example.com/download/example.jpg 的访问权限重写为http://one.other.com/example.jpg。当然,它对用户是不可见的。

    【讨论】:

    • 非常感谢,您的回答正是我所需要的
    • 这会导致 302 被返回给我的客户端,并带有更改后的 URL。我正在尝试更改发送到我的后端的请求。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-03
    • 1970-01-01
    相关资源
    最近更新 更多