我想将客户端 url "www.example.com/download.."操作为 "one.other.com/download..."
但我希望客户端上的 url 保持第一个“www.example.com/download”
Varnish 3 有没有办法做到这一点?
最佳答案
是的,您可以使用 regsub()
轻松完成此操作。 VCL 中的函数 vcl_recv
.
例如:
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
.当然,它对用户是不可见的。
关于url - 使用 Varnish 更改后端的 url 而不是客户端的 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14878877/