如何在vcl_backend_response中获取req.url?

jnb*_*bdz 16 varnish varnish-vcl

我的配置基于Varnish 3.0,我一直在更新它们.但是我陷入了困境.

vcl_fetch被取代了vcl_backend_response.在vcl_fetch你的内部曾经能够使用req.url但不再在内部vcl_backend_response.

所以我留下三个if不起作用的陈述:

sub vcl_backend_response {
     set beresp.do_esi = true;

     if (!(req.url ~ "wp-(login|admin)")) {
           unset beresp.http.set-cookie;
     }

     if ( req.http.host ~ "[0-9]\.example\.com" || req.http.host ~ "[0-9]\.example\.com") {
          set beresp.ttl = 60s;
     }

     if ( req.url ~ "\.(html|htm|css|js|txt|xml|svg)(\?[a-z0-9=]+)?$" ) {
          set beresp.do_gzip = true;
     }
}
Run Code Online (Sandbox Code Playgroud)

如何在Varnish 4.0版中转换这些配置?

顺便说一下,我是Varnish VCL的新手.

小智 35

你必须使用bereq.url在现在vcl_backend_response.