Varnish exclude url

I have a varnished 3.xx server that is currently running. Luck caches the login page of my site.

www.mysite.com/staff

but it may have different URLs depending on the link for employees, for example

www.mysite.com/staff/index.php?/Tickets/Ticket/View/222200

My varnish configuration file is set as follows to exclude caching of the page with the staff, but it does not work, because it caches the login page, and it does not log in until I restart the varnish to clear the cache.

sub vcl_recv { # Allow purge only from internal users if (req.request == "PURGE") { if (!client.ip ~ internal_net) { error 405 "Not allowed."; } return (lookup); # Exclude the following if (req.url ~ "^/login\.php" || req.url ~ "^/search\.php" || req.url ~ "^/admin(.*)" || req.url ~ "^/admin(.*)" || req.url ~ "^/search(.*)" || req.url ~ "^/visitor(.*)" || req.url ~ "^/staff(.*)" || req.url ~ "^/staff\.php" ) { return(pass); } if (req.http.cookie ~ "vb(.*)" || req.http.cookie ~ "bb(.*)" || req.http.cookie ~ "SWIFT_(.*)" || req.url ~ "\?(.*\&)?s=[a-fA-F0-9]{32}(\&|$)" || req.http.cookie ~ "bb_password") { return(pass); } else { unset req.http.cookie; } } 

Perhaps you have another method for excluding and caching the entire directory? IE: everything from / staff, no matter what, the suffix after that should not be cached

+4
source share
1 answer

The exception should work just the way you implemented it. However, if the code you entered is your actual VCL, you have the open if () statement in the PURGE section.

  sub vcl_recv { # Allow purge only from internal users if (req.request == "PURGE") { if (!client.ip ~ internal_net) { error 405 "Not allowed."; } return (lookup); # Exclude the following 

must read

  sub vcl_recv { # Allow purge only from internal users if (req.request == "PURGE") { if (!client.ip ~ internal_net) { error 405 "Not allowed."; } return (lookup); } # Exclude the following 

The varnish should not accept an invalid VCL, although if the error does not exist in your actual VCL, update this question with the whole VCL.

+3
source

Source: https://habr.com/ru/post/1443604/


All Articles