我想将客户端url"www.example.com/download.."操作为"one.other.com/download。。。但我希望客户端上的url保持第一个"www.example.com/download"
Varnish 3有办法做到这一点吗??
是的,您可以在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
。当然,它对用户来说是不可见的。