Files
RustProxy/examples/vcl/public-vhost-ignore-cookies.vcl
2026-11-20 19:51:27 +01:00

22 lines
1.1 KiB
Plaintext

// OPT-IN: use ONLY on an HTTP reverse-proxy Vhost with fully public,
// cookie-independent GET/HEAD content. Import into that Vhost, NOT globally.
// Useful when a parent domain sets Domain=.example.test cookies that a public
// sibling subdomain neither needs nor should forward to the backend.
//
// Cookie does not include the cookie's Domain attribute. It is IMPOSSIBLE
// to distinguish inherited cookies from host-only cookies in vcl_recv.
// This deliberately strips ALL cookies on permitted public paths; verify
// that users do not need login, preferences, locale, cart or affinity there.
// Customize the excluded path list to fit your application before enabling.
// Backend must return an eligible PUBLIC response (no private/no-store or
// Set-Cookie); this does not override response cache privacy or Vary.
sub vcl_recv {
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)(/|[?]|$)") {
unset req.http.Cookie;
return(hash);
}
}