Hello Hugo, Thank you for your answer.
It was most helpful!! Regards, Jaap On 11/23/11 12:49 PM, "Hugo Cisneiros (Eitch)" <[email protected]> wrote: > On Wed, Nov 23, 2011 at 9:32 AM, Jaap van Arragon > <[email protected]> wrote: >> Hello, >> >> Hopefully a short question: >> >> We have the following code in our VCL file: >> >> sub vcl_recv { >> >> # Purge through http >> if (req.request == "PURGE") { >> if (!client.ip ~ purge) { >> error 405 "Not allowed."; >> } >> ban("req.url =" + req.url + "&& req.http.host =" + req.http.host); >> error 200 "Purged."; >> } >> >> if (req.http.cookie) { >> unset req.http.cookie; >> return (lookup); >> } >> >> if (req.http.host ~ "example.url.com") { >> set req.backend = live; >> } >> else { >> error 404 "Unkown Virtual host"; >> } >> >> When our request ( example.url.com/asdja?adn23 ) comes in we see that the >> backend is selected which it first came across. We¹ve could pinpoint it to >> the unset.req.http.cookie part. If we move the unset cookie part under the >> req.http.host ~ "example.url.com" part it all goes fine. >> >> Can it be that the return(lookup); in the unset req.http.cookie part skips >> the req.http.host part? And thus the first backend is selected? > > Yes. The 'return(lookup)' after the 'unset req.http.cookie' will skip > all the rest of vcl_fetch. It will lookup in the cache and go to the > vcl_hit or vcl_pass depending if the object is found or not. > > You must place return(lookup) only after all required rules are done. > For example, I think this would work: > > if (req.http.cookie) { > if (req.http.host ~ "example.url.com") { > set req.backend = live; > } > else { > error 404 "Unkown Virtual host"; > } > > unset req.http.cookie; > return (lookup); > } > > Hope it will help. _______________________________________________ varnish-misc mailing list [email protected] https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc
