Files
RustProxy/examples/vcl/drupal6-parent-session-cookies.vcl
2026-11-20 23:14:19 +01:00

31 lines
1.7 KiB
Plaintext

// Opt-in example: this Vhost uses "session" while an unrelated Drupal 6 site
// at the parent domain sets cookies named SESS<hash> or SSESS<hash>.
// Requires RustProxy 0.39.2+ (return(cookie_pass); use return(pass) on 0.39.1).
// RustProxy 0.39.1 (with prefix selector support) only: remove_req_cookies()
// supports exact names and a single trailing '*' for case-sensitive prefixes.
// Not standard Varnish VCL. A normal 0.39.1 binary without this patch will
// treat "SESS*" as an exact literal name and WILL NOT strip Drupal cookies.
//
// Only install after confirming this Vhost never uses SESS* or SSESS* for
// authentication, personalization, CSRF protection, or other state.
// Keep CDN technical-cookie rules separate and later than this rule.
// Retain "CDN: bypass remaining cookies" to protect unknown session cookies.
sub vcl_recv {
// Subdomain's OWN login cookie must always skip the shared cache for
// pages. return(cookie_pass) (RustProxy extension) still lets public
// static assets use the cache under the static cookie policy; use
// return(pass) instead if even static files must bypass for this cookie.
if (req.http.Cookie ~ "(?:^|;[ \\t]*)session=") {
return(cookie_pass);
}
if ((req.method == "GET" || req.method == "HEAD") &&
req.http.Cookie &&
!req.http.Authorization &&
req.url !~ "^/(admin|api|auth|login|logout|account|profile|user|settings|dashboard|cart|checkout|panel|konto|wp-admin|wp-login[.]php)(/|[?]|$)") {
// Drupal 6 parent-domain session name changes with the site/hash.
// Analytics cookies below are also safe only when nonfunctional here.
remove_req_cookies("SESS*", "SSESS*", "_ga", "_ga_*", "_gid");
}
}