This commit is contained in:
Mateusz Gruszczyński committed 2026-11-20 21:56:12 +01:00
1 parent 08d1608ef5
commit d455028de3
16 files changed
+191 -48

No files matched your search

+3 -3
View File
@@ -21,7 +21,7 @@ For the **complete reference to all 42 quick-rule templates** (conditions, stage
| `vcl_recv` | `return(pass);` | Stops request processing for the matching path; bypasses shared cache. |
| `vcl_recv` | `return(hash);` or `return(lookup);` | Stops `vcl_recv` and requests a cache lookup. In compatibility mode, may admit a GET/HEAD carrying `Cookie` (with cookie-partitioned variants); other protections remain. |
| `vcl_recv` | `unset req.http.Cookie;` | Removes the **whole** request Cookie header, including what is forwarded to the origin. |
| `vcl_recv` | `remove_req_cookies("parent_analytics");` | **RustProxy extension:** removes only the specified exact-name cookie(s) from the request before later rules, cache lookup and origin forwarding. Remaining session cookies are not removed and can still trigger BYPASS. Not standard Varnish VCL. |
| `vcl_recv` | `remove_req_cookies("parent_analytics", "SESS*");` | **RustProxy extension:** removes exact-name cookies or case-sensitive prefixes marked by one trailing `*` before later rules, cache lookup and origin forwarding. Remaining session cookies are not removed and can still trigger BYPASS. Not standard Varnish VCL. |
| `vcl_recv` | `set req.http.X-Device = "mobile";` / `unset req.http.X-Tracking;` | Sets/removes a **safe request header** before later conditions, `vcl_hash`, cache policy and the forwarded origin request. Assignments are constant strings, and a per-vhost edit takes priority over a conflicting global edit. Authentication, identity, request cache policy and transport headers are protected (see below). |
| `vcl_recv` | `set req.url = regsuball(req.url, "([?&])(utm_[^=&]*|gclid)=[^&]*", "\1");` | **Restricted conversion only:** recognizes the specific captured-separator, query-parameter-removal pattern. Other `regsub` / `regsuball` rewrites are skipped with warnings; arbitrary URL regex replacement is not supported. |
| `vcl_hash` | `hash_data(req.http.X-Name);` | Adds one request header's value to RustProxy's **internal** variant key. It does not automatically add `Vary` for downstream caches. |
@@ -56,7 +56,7 @@ sub vcl_hash {
Both header edits are visible to later matching rules, the hash calculation and the origin. They also run on cache-disabled reverse-proxy routes (without enabling cache). They **do not** rewrite the client's original `Vary` requirements: if the response varies by `X-Device`, include it in `beresp.http.Vary` or configure it at the origin. A later `unset` is different from setting an empty string.
Protected request headers cannot be set or removed by general request rules: `Authorization`, `Cookie` (except dedicated whole-header `unset` or exact-name `remove_req_cookies(...)` actions), `Cache-Control`, `Pragma`, `Host`, range/precondition headers (`If-*`, `Range`), forwarding and origin identity headers (`Forwarded`, `Via`, `X-Forwarded-*`, `X-Real-IP`, `X-Client-IP`, `CF-Connecting-IP`, `True-Client-IP`), `Proxy-*`, `Sec-*`, `X-RustProxy-*`, `Content-Type`, `Expect` and the protected transport/body header list below. Rejected edits are warned about and never silently applied. Do not assume imported VCL can change authentication or request-cache restrictions.
Protected request headers cannot be set or removed by general request rules: `Authorization`, `Cookie` (except dedicated whole-header `unset` or selective `remove_req_cookies(...)` actions), `Cache-Control`, `Pragma`, `Host`, range/precondition headers (`If-*`, `Range`), forwarding and origin identity headers (`Forwarded`, `Via`, `X-Forwarded-*`, `X-Real-IP`, `X-Client-IP`, `CF-Connecting-IP`, `True-Client-IP`), `Proxy-*`, `Sec-*`, `X-RustProxy-*`, `Content-Type`, `Expect` and the protected transport/body header list below. Rejected edits are warned about and never silently applied. Do not assume imported VCL can change authentication or request-cache restrictions.
The query-removal conversion accepts only the supported captured-separator `regsuball` pattern. **Every such conversion emits a warning**, because removing parameters with RustProxy's parser can normalize separators differently from a regex replacement. Variable-name classes such as `utm_[a-z]+` are approximated by a prefix wildcard; value patterns ending in `[^&]+` may preserve empty values that `strip_query` removes. **Review generated parameters and warnings** if byte-exact URL behavior matters. Other URL rewrites are deliberately **not** guessed from keywords such as `utm_`.
@@ -148,7 +148,7 @@ sub vcl_recv {
}
```
Use `unset req.http.Cookie;` only when the origin does not need **any** cookies for that route. For a Vhost that receives cookies from a parent domain, prefer the [name-selective opt-in recipe](VCL_TRAFFIC_COOKBOOK.md#12-parent-domain-cookies-remove-selected-names-opt-in): `remove_req_cookies("exact_cookie_name");` is a **RustProxy-specific extension** that removes only named cookies, preserving session and other cookies for later rules. The separate CDN technical-cookie policy still has its own anchored allowlist and remaining-cookie pass. `Cookie` does not disclose the setting `Domain`, so a name must be verified outside RustProxy; avoid removing a name also used by this Vhost. A graphical **Strip cookies** action keeps an allowlist but is not equivalent to selective removal. In strict RFC mode (`cache.varnish_compatible=false`), `return(hash)` does not bypass the request Cookie restriction. `Authorization`, non-GET/HEAD traffic, request `no-store`, access/authentication and sticky-session checks still apply.
Use `unset req.http.Cookie;` only when the origin does not need **any** cookies for that route. For a Vhost that receives cookies from a parent domain, prefer the [name-selective opt-in recipe](VCL_TRAFFIC_COOKBOOK.md#12-parent-domain-cookies-remove-selected-names-opt-in): `remove_req_cookies("exact_cookie_name", "SESS*");` is a **RustProxy-specific extension** that removes exact names or a single trailing-`*` prefix, preserving other cookies for later rules. Use `SESS*` only when the Vhost never uses that session family; see the [Drupal 6 parent-domain example](../examples/vcl/drupal6-parent-session-cookies.vcl). The separate CDN technical-cookie policy still has its own anchored allowlist and remaining-cookie pass. `Cookie` does not disclose the setting `Domain`, so a name must be verified outside RustProxy; avoid removing a name also used by this Vhost. A graphical **Strip cookies** action keeps an allowlist but is not equivalent to selective removal. In strict RFC mode (`cache.varnish_compatible=false`), `return(hash)` does not bypass the request Cookie restriction. `Authorization`, non-GET/HEAD traffic, request `no-store`, access/authentication and sticky-session checks still apply.
## `no-cache` and TTL