我想操纵客户端网址“www.example.com/download ..”到“one.other.com/download ... 但我希望客户端上的网址保留第一个“www.example.com/download”
Varnish 3有没有办法做到这一点?
答案 0 :(得分:4)
是的,您可以使用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
的访问权限。当然,用户看不到它。