This commit is contained in:
Mateusz Gruszczyński committed 2026-11-20 20:54:40 +01:00
1 parent 53d92e0da6
commit 08d1608ef5
21 files changed
+928 -408

No files matched your search

+15 -4
View File
@@ -9,17 +9,28 @@ The **Static & diagnostics** subtab provides **Ignore request cookies for static
**Safety requirement:** use both options only when the complete static response (body **and headers**) is identical for all visitors regardless of Cookie. `Vary: Cookie` is a declaration that content may vary, so overriding it on a genuinely session-dependent file can expose one user's cached variant to another. RustProxy applies this override only to responses with an explicit `Cache-Control: public` directive, positive remaining freshness (without mandatory revalidation) and no `Set-Cookie`, `private`, `no-store` or invalid Vary. A zero-TTL response, including `public` with no configured fallback TTL, retains `Vary: Cookie` even if it can be stored for later revalidation. If the response is not cacheable, `Vary: Cookie` is passed through unchanged. Do not enable this optimization for user-specific downloads, generated PDFs, account JSON, or any path where Flask or another origin changes content according to a session cookie; prefer removing the needless `Vary: Cookie` at the origin where possible.
### Ready-made quick rules library
The **Add from template** dropdown is grouped by scenario. **Browse scenarios** opens a searchable panel with descriptions and one-click **Add** buttons for ready-made request, response and delivery rules. The library includes common application sessions, WordPress/WooCommerce, Django, Laravel, Auth.js, API and private routes, SSE/webhooks, TTL for verified public content and defensive headers. Some scenarios add multiple rules. Templates with a risk of unexpected shared-cache reuse are **disabled until reviewed**. The CDN and exact-name parent-domain cookie templates stay separate. See [Quick rules template library](CACHE_TEMPLATE_LIBRARY.md) for categories, order, defaults and tests. Adding rules changes the draft; save settings before relying on them.
### CDN security cookies (opt-in VCL template)
The cache rules template menu now includes **CDN technical cookies** for Cloudflare (`__cf_bm`, `cf_clearance`, `_cfuvid`, `__cfruid`, `__cfseq`) and Akamai (`_abck`, `ak_bmsc`, `bm_sz`, `bm_sv`). It bypasses non-GET/HEAD methods, restricted application paths and `Authorization`. It strips the entire Cookie header **only if all Cookie fields contain allowlisted technical cookies**, and bypasses any request with a remaining Cookie (for example `session`, `wordpress_logged_in_*`, CSRF tokens or other personalized cookies). The source equivalent is [`examples/vcl/cdn-technical-cookies.vcl`](../examples/vcl/cdn-technical-cookies.vcl). Import it only after reviewing warnings; enable the graphical template only on tested public Vhosts. Some challenge cookies (especially `cf_clearance`, `_abck` and `ak_bmsc`) are important to specific origin/CDN configurations; removing them can break a challenge flow. **This is not turned on automatically for existing Vhosts.**
### Inherited cookies on public Vhosts (opt-in, disabled by default)
### Parent-domain cookies: opt-in per-Vhost name filtering
A parent domain may set `Set-Cookie: name=value; Domain=.example.test`, causing browsers to send it to *all* subdomains. A received `Cookie` header contains only names and values: RustProxy **cannot determine the source Domain** or whether a cookie was set by the current subdomain. The preferred fix is to make the cookie host-only at the issuing application (omit `Domain`), if it is not meant for sibling hosts.
A parent domain may set `Set-Cookie: name=value; Domain=.example.test`, making browsers send it to subdomains. The incoming `Cookie` header **does not include the Domain attribute**: RustProxy cannot distinguish the parent cookie from a cookie with the same name set by this Vhost. Prefer configuring host-only cookies (omit `Domain`) at the issuing application.
For a subdomain that serves **exclusively public, cookie-independent GET/HEAD pages**, the Vhost **Cache rules → Add from template → Public vhost: ignore inherited cookies** template is available. It is deliberately **disabled when added**, absent from the global template menu, and must be reviewed before enabling. The template strips **all incoming request cookies** before lookup **and** before forwarding to the origin, only for GET/HEAD with Cookie, without `Authorization`, and outside its conservative private-path exclusion regex. The path regex is only an example; adapt it to the application. Do not use on logged-in pages, language/session-dependent pages, checkout, downloads, CSRF or custom authenticated paths. A public page must return identical body and headers regardless of Cookie; otherwise do not enable the rule. The independently importable VCL equivalent is [`examples/vcl/public-vhost-ignore-cookies.vcl`](../examples/vcl/public-vhost-ignore-cookies.vcl).
Two **separate** opt-in templates remain available in the Vhost cache-rule editor:
This rule does not remove an origin `Vary: Cookie` header. Since Cookie has been removed from the request before lookup and the backend fetch, all eligible requests compare the **absent** Cookie variant. RustProxy still requires normal response eligibility: `Cache-Control` privacy, `Set-Cookie`, response `Vary`, authentication and route checks remain active. If the origin emits an unnecessary `Vary: Cookie` for a truly public page, correct it at the origin rather than unsetting all `Vary` in a deliver-stage rule. Avoid installing the new template *after* a same-scope early `pass` rule for Cookie: stop/return prevents later rules running. Prefer the **per-Vhost editor** and verify `X-Cache-Reason` with a real browser Cookie before rollout.
1. **Vhost: remove selected parent-domain cookies** (inserted **disabled**): the operator supplies an exact comma-separated list of **non-session** cookie names in the `Remove only named cookies` action, replacing `REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME`. Only those names are removed from incoming GET/HEAD requests; every other cookie, including the application's session, stays intact. The rule has **no** `return(hash)` and **does not stop** subsequent cache rules. It excludes Authorization and example private paths; review the path list for your application. The example is [`examples/vcl/public-vhost-remove-parent-cookies.vcl`](../examples/vcl/public-vhost-remove-parent-cookies.vcl).
2. **CDN technical cookies** (independent, unchanged): its safe-method/private-path/Authorization guards, its anchored whole-header CDN cookie allowlist and **CDN: bypass remaining cookies** continue to run after parent cookie removal. It never treats a remaining session cookie as a CDN cookie. See [`examples/vcl/cdn-technical-cookies.vcl`](../examples/vcl/cdn-technical-cookies.vcl).
**Order:** place the parent-name rule **above** `CDN: remove ONLY technical cookies` and especially **above** `CDN: bypass remaining cookies`; leave the CDN guard rules active at the top. **Delete/disable any old `Public vhost: ignore inherited cookies` rule that uses `strip_cookies: keep=[]` + `lookup`**. Updating the binary does not remove existing saved rules. Never add an application session cookie, login token, CSRF token, locale/personalization cookie or sticky-session identifier to the parent-name list. Do not wildcard cookie names. If the same cookie name can belong to the parent **and** this application, use host-only cookies at the issuer instead of the removal rule.
Resulting request behavior on public pages: `Cookie: parent_marketing=1` (listed) → stripped → cache eligible; `Cookie: parent_marketing=1; __cf_bm=2` → parent removed by this rule, then CDN removed by its separate template → eligible; `Cookie: parent_marketing=1; app_session=abc` → only parent removed, session retained → CDN remaining-cookie rule **BYPASS**; POST, Authorization and private paths are not rewritten by the new template. Verify each using **Cache rule tester** and live `X-Cache-Reason` headers. Responses with `Set-Cookie`, `private` or `no-store` still cannot enter shared storage. The origin's `Vary: Cookie` stays intact and is evaluated against the **remaining** Cookie value. Configure logged-in origin responses as `private, no-store` as defense in depth.
The import syntax `remove_req_cookies("name1", "name2");` is a **RustProxy-specific VCL extension**, not stock Varnish syntax. It performs exact, case-sensitive name matching, preserves other cookies, and refuses to rewrite malformed Cookie fields. A graphical `Remove only named cookies` action uses the same implementation. This new action is not the dangerous `Strip cookies` / "keep" operation, which can remove other cookies.
**Do not extend** `Ignore Vary: Cookie for public static assets` to a general "Ignore Vary" control. `Accept-Encoding`, `Accept-Language`, `Accept`, `Origin`, `User-Agent` and custom response-specific dimensions can change bytes, permissions or CORS headers. Keep the response's actual dimensions and use the existing safe normalization of recognized list fields below, or remove an unnecessary `Vary` at the origin only after proving the response is invariant. A VCL `unset beresp.http.Vary` is *possible*, but it is not the equivalent of a guarded static-file optimization.
+163
View File
@@ -0,0 +1,163 @@
# Cache rule template library: all 42 scenarios
**Applies to RustProxy 0.39.1.** This reference documents the 42 scenarios shipped by the graphical **Add from template...** and **Browse scenarios** controls. It describes the rules actually generated by `src/admin/web/cache-rules.js`, including their initial enabled state, exact matching scope, effects and limitations. The seven sections below follow the panel's category order.
These are **graphical cache rules**, not scripts executed by a Varnish VCL engine. The panel can export a readable VCL preview, but that export is not a lossless rule backup. For the VCL import subset, see [VCL.md](VCL.md); for copyable VCL examples, see the [traffic cookbook](VCL_TRAFFIC_COOKBOOK.md).
## Add, configure and activate a template
1. Open **Vhost -> Cache -> Cache rules** (including a Docker-generated Vhost), or **Settings -> Cache -> Rules** for global rules. Only Vhost editors offer the parent-domain cookie template.
2. Choose **Add from template...**, or open **Browse scenarios**, search by name/description and click **Add**. A scenario inserts **one or more ordinary rules**. Adding does not save the configuration.
3. Expand the new rules. Check the match mode (**all** vs **any**), paths, cookie names, headers and TTL. Enable rules marked **Off** only after adaptation. Review their order relative to other Vhost and global rules.
4. Use **Test a request** with anonymous, session-cookie, `Authorization` and sensitive-path examples. Save the settings, test with real GET requests and inspect `X-Cache`, `X-Cache-Reason`, `Age` and `Cache-Status`.
5. **Purge existing cache entries** after changing privacy or representation boundaries. New no-store or BYPASS rules cannot retrospectively remove already-stored objects.
A template is **On** if its generated rule(s) are enabled when inserted; **Off** means deliberate opt-in is required. **Request** rules alter or bypass a request before cache lookup; **response** rules control backend response storage; **deliver** rules change outgoing response headers, including on HIT. **Deliver-only `Cache-Control: no-store` does not disable RustProxy's shared cache.** Multi-rule scenarios insert all their rules together; exceeding the 128-rule limit rejects the group.
## 1. Security and private content (15 scenarios)
| Template (internal key) | Rules / default | Match and precise behavior | Configuration / caveat |
|---|---|---|---|
| **Methods other than GET/HEAD** (`safemethods`) | 1 request, **On** | Method is not GET or HEAD -> `pass` (BYPASS). | Usually a safe guard for forms and writes. Other method restrictions still come from RustProxy's normal cache policy. |
| **Authorization** (`authbypass`) | 1 request, **On** | An `Authorization` request header exists -> `pass`. | Applies to any route. Do not try to compensate by removing the header. |
| **Any Cookie** (`cookiepass`) | 1 request, **On** | Any `Cookie` header exists -> `pass`. | Conservative for unknown apps; place **after** a selective parent-domain/CDN cleanup if those cookies should be ignored. |
| **Common session cookies** (`sessioncookies`) | 1 request, **On** | Cookie header contains an exact cookie-name boundary for `session`, `sessionid`, `PHPSESSID`, `laravel_session`, `connect.sid` or `sid` -> `pass`. | Not an exhaustive session list. Add app-specific names or use **Any Cookie** as a fallback. |
| **Private account routes** (`privateroutes`) | 3: request + response + deliver, **On** | Paths starting with a complete segment `admin`, `auth`, `login`, `logout`, `user`, `users`, `account`, `profile`, `settings`, `dashboard`, `cart`, `checkout`, `orders`, `billing` or `payment`: `pass`, block storage and deliver `Cache-Control: private, no-store`. | Review locale prefixes, custom account URLs and API routes. Purge previously cached responses. |
| **Preview or draft links** (`preview`) | 1 request, **On** | Path segment `/preview` or `/draft`, **or** a `preview`/`draft` query parameter -> `pass`. | Add other preview token names as needed. A query parameter's mere presence is sufficient. |
| **Cart / checkout / payments** (`checkout`) | 1 request, **On** | `/cart`, `/checkout`, `/payment`, `/billing`, `/order`, `/orders` (and descendants) -> `pass`. | Does not by itself send browser no-store; configure application/private responses accordingly. |
| **Webhooks / callbacks** (`webhooks`) | 1 request, **On** | `/webhook`, `/webhooks`, `/callback`, `/callbacks` or `/hooks` (and descendants) -> `pass`. | Adapt nonstandard callback endpoints. This changes cache routing, not webhook authentication. |
| **Health and metrics** (`healthchecks`) | 1 request, **On** | `/health`, `/healthz`, `/readyz`, `/livez`, `/metrics`, `/status` -> `pass`. | Does not block public access to those endpoints; protect sensitive metrics separately. |
| **GraphQL** (`graphql`) | 1 request, **On** | `/graphql` and descendants -> `pass` even for GET requests. | Conservative when GraphQL queries can depend on the user. Other GraphQL endpoint paths need separate rules. |
| **SSE and WebSocket** (`streaming`) | 1 request, **On** | `Accept` contains `text/event-stream` **or** an `Upgrade` request header exists -> `pass`. | Streaming/upgrades should not be served from a normal HTTP object cache. |
| **Signed query URLs** (`signedurls`) | 1 request, **On** | Query contains any of `token`, `access_token`, `signature`, `sig`, `auth_token` -> `pass`. | Update the list for the app's signed parameter names. The rule matches name presence, not token validity. |
| **All HTML no-store** (`nocachehtml`) | 2: response + deliver, **On** | Backend `Content-Type` begins `text/html`: prevent shared-cache storage and deliver browser `Cache-Control: no-store`. | **No request-stage pass** is added. Purge old HTML objects to avoid serving pre-existing HITs. |
| **Private API** (`privateapi`) | 3: request + response + deliver, **On** | Path starts with `/api/private/`: `pass`, prevent storage and send `Cache-Control: private, no-store`. | Does not automatically cover `/api/private` without `/`, `/v1/...` or other private API prefixes. |
| **Private downloads** (`privatedownloads`) | 2: request + deliver, **Off** | Example prefix `/private-downloads/`: `pass` plus browser `Cache-Control: private, no-store`. | **Replace the sample prefix**, enable both rules and purge older objects. It adds no response-stage `no_store` rule. |
These templates are **cache protections, not authentication or authorization**. The origin must still enforce access control, and should return `Cache-Control: private, no-store` for user-specific responses.
## 2. CMS and framework sessions (7 scenarios)
All seven insert a **request-stage `pass` rule, enabled by default**. They **retain** cookies and forward them to the backend; none rewrites a session cookie.
| Template (internal key) | Trigger | Use and adjustments |
|---|---|---|
| **WordPress** (`wordpress`) | Path begins `/wp-admin`, `/wp-login.php`, `/xmlrpc.php` or `/wp-json`; **or** Cookie contains `wordpress_logged_in_`, `comment_author_`, `woocommerce_items_in_cart` or `wp-postpass_`. | Protects dashboard, login, REST endpoints and common session/comment cookies. Check custom login and REST routes. |
| **WooCommerce** (`woocommerce`) | `/cart`, `/checkout`, `/my-account`; **or** Cookie has `wordpress_logged_in_*`, `woocommerce_items_in_cart`, `wp_woocommerce_session_*` or `woocommerce_cart_hash`. | Protect cart/account/session traffic. Add localized/custom checkout routes and session-cookie names. |
| **Django** (`django`) | Named Cookie `sessionid` exists. | Adjust the exact name if the application overrides `SESSION_COOKIE_NAME`. Does not match a differently named session. |
| **Laravel / PHP** (`laravel`) | Cookie `laravel_session` or `PHPSESSID` exists. | Account for custom PHP/Laravel session names; may need CSRF/private-path rules. |
| **Auth.js / NextAuth** (`authjs`) | Cookie `authjs.session-token` or `next-auth.session-token`, optionally prefixed with `__Secure-`. | Extend for other Auth.js token/session cookie names and custom prefixes. |
| **ASP.NET** (`aspnet`) | Cookie `.AspNetCore.Cookies` or `ASP.NET_SessionId` exists. | Adapt to the app's authentication scheme/custom cookie names. |
| **Drupal** (`drupal`) | Cookie name has `SESS` or `SSESS` followed by one or more hexadecimal characters. | Captures common Drupal session names; confirm site-specific prefixes and authenticated routes. |
A framework template recognizes only the listed paths or cookie names. Where a session could use **any other cookie name**, keep the conservative **Any Cookie** guard (after any verified cookie cleanup) until the app has been audited.
## 3. CDN and inherited cookies (2 independent scenarios)
| Template (internal key) | Rules / default | Exact effect | Deployment notes |
|---|---|---|---|
| **CDN technical cookies** (`cdn`) | 5 request rules, all **On** | `pass` non-GET/HEAD; `pass` `/admin`, `/api`, `/auth`, `/login`, `/logout`, `/panel`, `/konto`, `/dashboard`; `pass` `Authorization`; strip **the entire Cookie header only if every cookie name** belongs to the fixed Cloudflare/Akamai technical list; then `pass` if any Cookie remains. | Do not replace the anchored allowlist with a contains/substring match. Cookie names: `__cf_bm`, `cf_clearance`, `_cfuvid`, `__cfruid`, `__cfseq`, `_abck`, `ak_bmsc`, `bm_sz`, `bm_sv`. Use only if those values are irrelevant to the origin's representation. |
| **Selected parent-domain cookies** (`publiccookies`) | 1 request rule, **Off**; **Vhost-only** | Only on GET/HEAD with Cookie, without Authorization and outside specified private prefixes: remove **only exact cookie names** entered by the operator; no forced cache lookup and no `stop`. | Replace `REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME` with verified, nonsession names. Other cookies remain and can trigger the CDN remaining-cookie `pass` guard. |
**Safe order for a Vhost using both:**
1. CDN method, private-path and Authorization `pass` guards.
2. **Selected parent-domain cookies** (only verified names; enabled after review).
3. CDN technical-cookie stripping (only technical-only Cookie headers).
4. CDN **BYPASS remaining cookies** guard.
A separate **Any Cookie** guard should also follow the cookie cleanup if used. The parent-domain template is automatically inserted before existing CDN stripping/remaining-cookie rules **within the same editor**; it does not rearrange saved rules in another scope. Vhost-stage rules are evaluated ahead of applicable global rules. Never enable an old **ignore all inherited cookies** rule that calls `strip_cookies` for every name and then forces lookup.
**Why names must be verified:** request `Cookie` carries *names and values*, not the `Domain` attribute that originally set the cookie. RustProxy cannot automatically tell whether it came from a parent host. If the parent site and application use the **same** cookie name for different purposes, name-based deletion is unsafe. Prefer host-only cookies at the issuer or an explicit per-route design instead. Removing a Cookie changes both the cache decision **and** what the backend receives.
For copyable VCL syntax, see [parent-domain cookie removal](VCL_TRAFFIC_COOKBOOK.md#12-parent-domain-cookies-remove-selected-names-opt-in), [`public-vhost-remove-parent-cookies.vcl`](../examples/vcl/public-vhost-remove-parent-cookies.vcl) and [`cdn-technical-cookies.vcl`](../examples/vcl/cdn-technical-cookies.vcl). The selective `remove_req_cookies(...)` instruction is a **RustProxy extension**, not standard Varnish VCL.
## 4. Public content and cache TTL (10 scenarios)
Response-stage TTL rules only affect *otherwise eligible* responses. They do not override private/no-store cache policy, `Set-Cookie`, `Vary`, authentication, object limits or the **HTTP 200 only** storage restriction in RustProxy 0.39.1. They do not necessarily change `Cache-Control` seen by a browser.
| Template (internal key) | Rules / default | Match and actions | Enable only when... |
|---|---|---|---|
| **Public JSON API** (`publicjson`) | 1 response, **Off** | Prefix `/api/public/`, status 200 and `Content-Type: application/json*` -> TTL **60 s**, grace **30 s**. | API payload is identical for all eligible users and its `Vary`/cache headers are correct. |
| **Blog / catalog HTML** (`publicpages`) | 1 response, **Off** | `/blog`, `/news`, `/articles`, `/catalog`, `/products` and descendants; status 200, `text/html*` -> TTL **300 s**, grace **60 s**. | Pages do not contain per-user names, carts, account data or other personalized fragments. |
| **RSS / Atom** (`feeds`) | 1 response, **Off** | `/feed`, `/rss`, `/rss.xml`, `/atom.xml` and descendants; status 200 -> TTL **600 s**. | Feeds are public; review any authenticated/custom feed endpoints. |
| **Sitemap XML** (`sitemap`) | 1 response, **Off** | `/sitemap.xml`, `/sitemap_index.xml` or `/sitemap/...`; status 200 -> TTL **3600 s**. | Sitemap URLs are stable/public and updates can tolerate up to an hour of caching. |
| **Filename-hashed assets** (`hashedassets`) | 1 response, **Off** | Under `/assets/`, `/static/`, `/build/` with a hash-like filename segment (at least 8 allowed characters), known JS/CSS/image/font extension and status 200 -> TTL **31,536,000 s** (1 year). | Filenames really change on content updates; the pattern itself cannot prove immutability. |
| **Images** (`imagecache`) | 1 response, **Off** | Extensions `png`, `jpg`, `jpeg`, `webp`, `avif`, `gif`, `svg`; status 200 -> TTL **86,400 s** (1 day). | No private avatars, signed assets or user-specific image URLs are matched. |
| **Fonts** (`fontcache`) | 1 response, **Off** | Extensions `woff`, `woff2`, `ttf`, `otf`; status 200 -> TTL **2,592,000 s** (30 days). | Font files and licensing/access requirements allow public reuse. |
| **Search results** (`searchttl`) | 1 response, **Off** | Path starts with `/search` and status 200 -> TTL **15 s**. | Responses are genuinely public. Prefix also matches similar paths such as `/searchable`; narrow it if needed. |
| **Static files: strip cookies + TTL** (`static`) | 2: request + response, **On** | Known static extensions: remove **all request cookies**. On status 200 set TTL **2,592,000 s** (30 days) and remove backend `Set-Cookie`. | **Audit carefully:** this existing template changes what the origin receives and can be unsafe for protected/downloaded resources whose path looks static. |
| **Remove tracking query params** (`tracking`) | 1 request, **On** | Remove `utm_*`, `fbclid`, `gclid`, `msclkid`, `mc_cid`, `mc_eid`, `_ga` from the request URL/cache key. | The backend never uses those parameters to choose response contents, permissions or redirects. |
**Important distinction:** the `static` and `tracking` legacy templates start **On**, unlike the eight newly introduced TTL scenarios. Review them when the Vhost serves protected or parameter-dependent resources.
## 5. Cache-key variants (1 scenario)
| Template (internal key) | Rules / default | Behavior | Limitation |
|---|---|---|---|
| **Language cookie** (`language`) | 1 request, **On** | Add the named `lang` cookie to RustProxy's internal cache variant key (`hash_cookie`). | This does **not** bypass the ordinary request-cookie restriction and does **not** automatically generate downstream `Vary: Cookie`. Align the origin's representation policy and actual language cookie name. |
## 6. Outgoing response headers (6 scenarios)
These run at the **deliver** stage. Unless accompanied by request/response rules, they do not affect whether RustProxy reads or writes shared cache objects.
| Template (internal key) | Rules / default | Match and action | Limitations |
|---|---|---|---|
| **Hide X-Powered-By** (`headers`) | 1 deliver, **On** | Remove outgoing `X-Powered-By` for every response. | Does not change a header already stored in the cache object or remove other information leaks. |
| **Browser-cache static assets** (`browser`) | 1 deliver, **On** | Known CSS/JS/image/font extensions, status 200 -> `Cache-Control: public, max-age=2592000` (30 days). | This also changes outgoing headers on BYPASS. Use only for genuinely public static resources. |
| **No browser cache for HTML/admin** (`nobrowser`) | 1 deliver, **On** | **Any** of: `Content-Type` starts `text/html`, path starts `/admin` or path starts `/account` -> `Cache-Control: no-store`. | **Only browser cache** is affected. Add response `no_store` or a request `pass` rule to prevent shared-cache reuse. |
| **Default security headers** (`security`) | 1 deliver, **On** | If absent, set `X-Content-Type-Options: nosniff` and `Referrer-Policy: strict-origin-when-cross-origin`. | Does not overwrite existing origin values. Review security policy with the application. |
| **Staging noindex** (`stagingnoindex`) | 1 deliver, **Off** | If absent, set `X-Robots-Tag: noindex, nofollow` on all responses. | Preventing search indexing is **not** access control; enable only on staging/private search surfaces after review. |
| **Frame protection** (`frameguard`) | 1 deliver, **Off** | If absent, set `X-Frame-Options: SAMEORIGIN` on all responses. | May break legitimate embedding or iframe flows; adapt to the site's CSP and embedding requirements. |
## 7. Other / broad API protection (1 scenario)
| Template (internal key) | Rules / default | Behavior | Limitations |
|---|---|---|---|
| **API: bypass cache** (`api`) | 1 request, **On** | Path starts `/api/` -> `pass`. | Covers both private and public API endpoints. It does not send browser `no-store`; for public JSON caching remove or narrow this broad pass guard first. |
## Rule-order pitfalls
- **`pass` takes precedence over later request edits:** if **Any Cookie** or **CDN BYPASS remaining cookies** runs first, a later parent-name cleanup rule never gets a chance to remove irrelevant cookies. This is the typical reason a browser shows `X-Cache: BYPASS` with `X-Cache-Reason: cache_rule` while a cookie-free `curl` gets HIT.
- **A `pass` after selective cleanup still sees app sessions:** `parent_analytics=1; app_session=abc` must become `app_session=abc`, and the remaining-cookie guard must BYPASS. Never force `lookup` to override this.
- **Global vs Vhost scope matters:** matching Vhost rules run before applicable global rules. Ordering controls in one list do not reorder the other list. A terminal request action stops further normal request-stage evaluation; response and deliver stages are separate.
- **A broad API guard can defeat public API TTL:** request `pass` on `/api/` makes a response-stage public JSON TTL irrelevant. Narrow the prefix or use a dedicated public route when desired.
- **Browser `Cache-Control` is not proxy cache policy:** a deliver-only `no-store` or `public` header can differ from RustProxy's internal HIT/MISS decision. Protect user-specific content in request/response stages and at the origin.
- **`Vary` matters:** a response with `Vary: Cookie` or `Vary: Accept-Encoding` can legitimately produce separate variants. A browser refresh can send `Cache-Control: no-cache` or `max-age=0`; inspect the original request headers before concluding the cache is broken.
## Verification matrix
Use the panel's **Test a request** first, then verify with repeated real GET requests. Expected results below assume the relevant templates are enabled and ordered as described:
| Request | Expected behavior |
|---|---|
| Anonymous `GET /catalog` | Normal cache eligibility; first GET can be MISS, next can be HIT. |
| `GET /catalog` with **only** a verified parent cookie | Exact name removed; lookup may proceed. |
| Same URL with `parent_analytics=1; app_session=abc` | Parent cookie removed, session retained -> later BYPASS. |
| Cookie header containing only listed CDN technical cookies | CDN template may remove the entire technical-only header; lookup may proceed. |
| Mixed CDN technical cookie and session | CDN filter does **not** strip the mixed header -> BYPASS. |
| `GET /account/orders` | Private-path rule -> BYPASS, backend no-store, browser `private, no-store`. |
| `GET /api/private/me` | Private API rule -> BYPASS and no-store. |
| `GET /?preview=1` | Preview rule -> BYPASS. |
| `GET /graphql` | GraphQL rule -> BYPASS. |
| `POST /checkout` | Non-GET/HEAD or checkout rule -> BYPASS. |
| Anonymous `GET /api/public/items` with public 200 JSON | Potential TTL 60 s only if public JSON was enabled **and** no broader `/api/` pass rule matched. |
Example HTTP test (use **the same URL and GET method** repeatedly):
```bash
URL="https://example.com/catalog"
for i in 1 2 3; do
curl -sS -o /dev/null -D - "$URL" \
| grep -Ei '^(HTTP/|x-cache:|x-cache-reason:|age:|cache-status:)'
done
# Separate expected BYPASS test for an app session cookie:
curl -sS -o /dev/null -D - \
-H 'Cookie: app_session=example' "$URL" \
| grep -Ei '^(x-cache:|x-cache-reason:|cache-status:)'
```
In case of unexpected results, compare the browser's **request** `Cookie`, `Authorization`, `Cache-Control`, exact URL, method and `Accept-Encoding` against curl. Use the tester's matched-rule names; check Vhost vs global scope and the placement of any terminal `pass`. Check the backend's `Cache-Control`, `Set-Cookie`, status and `Vary` before changing storage rules.
See also [Cache](CACHE.md), [VCL support matrix](VCL_SUPPORT_MATRIX.md), [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) and [Security](SECURITY.md).
+2 -1
View File
@@ -73,7 +73,8 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
- Optional minification of JavaScript, CSS, HTML, SVG and JSON with memory budgets.
![Cache](images/cache.png)
- Opt-in disabled-by-default per-Vhost template for fully public pages to ignore all inherited parent-domain cookies on GET/HEAD (with Authorization/private-path guards); no global cookie strip or source-domain guessing.
- Searchable **quick-rule template gallery** in global/Vhost/Docker cache editors: grouped ready-made session/privacy, CMS/framework, CDN/parent-cookie, API/GraphQL, public TTL, static assets and response-header scenarios. Risky cache-acceleration templates are disabled until reviewed; examples are documented in [Quick rules library](CACHE_TEMPLATE_LIBRARY.md).
- Separate disabled-by-default per-Vhost template for exact-name removal of verified non-session parent-domain cookies; unrelated/session cookies survive and the unchanged CDN template can independently strip CDN-only cookies or bypass remaining sessions. No automatic cookie Domain detection.
- CDN security-cookie template (Cloudflare and Akamai) that strips whole Cookie headers only when every cookie is allowlisted, with session/Authorization/path bypass; opt-in for verified public content. The [VCL support matrix](VCL_SUPPORT_MATRIX.md) documents supported and deliberately excluded constructs.
- **VCL subset only:** graphical rules are the canonical configuration. Partial imports require review; the VCL text shown in the editor is an approximate preview. Cache storage is restricted to HTTP 200 (non-200 responses can still receive deliver-header rules). See [VCL import](VCL.md).
+2 -1
View File
@@ -37,7 +37,8 @@ Guides for operating RustProxy: installation, publishing services, security, cer
## Performance and delivery
- [Cache](CACHE.md) — scope-aware Cache & VCL help modal from global/Vhost/Docker editors, a compact rule tester, HOT/COLD cache, RFC 9111 `Vary` matching/normalization, safe static-asset cookie exceptions, freshness, `Cache-Status` and invalidation.
- [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) — 12 ready-to-import examples, public/private HTTP traffic cases, Cookie/`Vary` variants, `curl` verification and failure modes.
- [Quick rules template library](CACHE_TEMPLATE_LIBRARY.md) — searchable grouped scenarios for sessions, CDN/parent cookies, frameworks, public APIs, assets, no-store and security headers; defaults, risks and smoke tests.
- [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) — 12 ready-to-import examples, separate name-selective parent-domain and CDN cookie rules, Cookie/`Vary` variants, `curl` verification and failure modes.
- [Complete VCL support matrix](VCL_SUPPORT_MATRIX.md) — line-by-line supported, restricted, graphical-only, intentionally excluded and missing instructions, with test scenarios.
- [VCL compatibility and header overrides](VCL.md) — supported VCL import syntax, safe request-header edits, `beresp.uncacheable` precedence, `Vary`, cookies, approval of partial imports and storage limits.
- [Response delivery](RESPONSE_DELIVERY.md) — compression, transformations and response headers.
+4 -3
View File
@@ -4,7 +4,7 @@ This guide describes the VCL **subset implemented by RustProxy 0.39.1**, not the
For a short operational reference inside the panel, open **Cache & VCL guide** from **Settings → Cache**, the ordinary **Vhost → Cache** editor or **Docker vhosts → Cache**. The same modal works in all three places; example VCL is pasted into the importer of the editor that opened the guide, and the modal labels that scope. The modal shows the current compatibility-mode, fallback-TTL and grace settings, explains `Vary` and header mutations with examples, and identifies unsupported Varnish hooks. It complements this exact syntax reference; it does not execute VCL or save settings.
For an expanded **implemented / restricted / graphical-only / intentionally excluded / not implemented** inventory, consult the [complete VCL support matrix](VCL_SUPPORT_MATRIX.md). For practical production scenarios, **12 copyable VCL examples**, HTTP traffic outcomes, a `curl` validation plan and troubleshooting, use the [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) (also available from the embedded Reader). It names each supported hook, variable and return action and the deliberate HTTP/security boundaries.
For the **complete reference to all 42 quick-rule templates** (conditions, stages, defaults, cookie/session safety, TTL and testing), see the [Cache rule template library](CACHE_TEMPLATE_LIBRARY.md). These graphical presets are distinct from directly importable VCL. For an expanded **implemented / restricted / graphical-only / intentionally excluded / not implemented** inventory, consult the [complete VCL support matrix](VCL_SUPPORT_MATRIX.md). For practical production scenarios, **12 copyable VCL examples**, HTTP traffic outcomes, a `curl` validation plan and troubleshooting, use the [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) (also available from the embedded Reader). It names each supported hook, variable and return action and the deliberate HTTP/security boundaries.
## Where to import, rule order and activation
@@ -21,6 +21,7 @@ For an expanded **implemented / restricted / graphical-only / intentionally excl
| `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` | `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. |
@@ -55,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 the existing dedicated whole-header `unset`), `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 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.
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_`.
@@ -147,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 public Vhost that receives cookies from its parent domain, see the [opt-in inherited-cookie recipe](VCL_TRAFFIC_COOKBOOK.md#12-public-vhost-inherited-cookies-opt-in). `Cookie` does not disclose the setting `Domain`, so this is an intentional all-cookie removal, not automatic recognition of inherited cookies. A graphical **Strip cookies** action can keep an allowlist (not imported from arbitrary VCL cookie rewriting). 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");` 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.
## `no-cache` and TTL
+5 -4
View File
@@ -81,11 +81,12 @@ Do **not** use an unanchored regex such as `req.http.Cookie ~ "__cf_bm"` with `u
|---|---|---|
| `return(pass);` | Supported | Cache bypass; terminates applicable request-stage rules and skips `vcl_hash`. |
| `return(hash);`, `return(lookup);` | Supported with safety conditions | Explicit lookup; in Varnish-compatibility mode can admit **Cookie-bearing GET/HEAD** requests, partitioned by their remaining Cookie value and with downstream `Vary: Cookie`. Does not override Authorization, unsafe methods, client privacy or disabled cache. |
| `unset req.http.Cookie;` | Supported | Removes **every** Cookie value before subsequent rules, origin forwarding and cache key generation. No per-name deletion in imported VCL. |
| `unset req.http.Cookie;` | Supported, risky | Removes **every** Cookie value; never use for a session-bearing Vhost. |
| `remove_req_cookies("exact_name", "another_name");` | Supported, RustProxy extension | Deletes **only** selected exact Cookie names on the request, retaining other cookies for later pass/cache checks; refused on malformed Cookie fields. Not stock Varnish VCL. |
| `set req.http.X-Name = "literal";` | Supported with protected-name list | Changes a safe request header to a constant string. Origin sees the change. Dynamic/compound expressions are not recognized. |
| `unset req.http.X-Name;` | Supported with protected-name list | Removes all values of an allowed request header. |
| `set req.url = regsuball(req.url, "...", "\\1");` | Restricted | Only a pattern that matches a captured query separator plus a known parameter-name list is converted to `strip_query`; importer warns about separator/empty-value differences. See [VCL details](VCL.md#request-header-changes-scope-and-safeguards). |
| `set req.http.Cookie = regsuball(...)`, single-cookie deletion, `regsub()` on cookies | Not implemented | Use graphical **Strip cookies / Keep these cookies** instead. An imported VCL expression will **not** safely delete one cookie from a list. |
| `set req.http.Cookie = regsuball(...)`, `regsub()` on cookies | Not implemented | Arbitrary Cookie regex rewrites are unsafe and not imported; use `remove_req_cookies()` or graphical **Remove only named cookies** for selective removal. |
| `set req.backend_hint`, `set req.method`, `set req.hash`, `set req.http.Authorization` | Unsupported (intentional boundary) | Request origin selection, security identity, method, HTTP framing and credentials remain controlled by RustProxy's normal Vhost/route/auth machinery. |
| `return(pipe)`, `return(purge)`, `return(synth(...))`, `return(restart)` | Not implemented | Warnings, not equivalents to `pass` or other rules. |
| `return(deliver)` in `vcl_recv` | Not implemented | This is not a supported return target in the request stage. |
@@ -205,9 +206,9 @@ The labels above distinguish explicit product limits from missing work; **not im
5. On a real, authorized test origin send two identical requests to compare MISS/HIT and a changed Vary dimension to ensure distinct variants. The rule tester **cannot replace** this test.
6. For Docker services, repeat after a container disappears and returns, checking the same saved Vhost assignment and the Cache/Traffic scope labels.
### Included opt-in public-Vhost inherited-cookie policy
### Included opt-in parent-domain cookie rule (separate from CDN)
The graphical **Public vhost: ignore inherited cookies** template (`src/admin/web/cache-rules.js`) is available only in local Vhost/Docker Vhost rule editors and inserted disabled. It deliberately drops the **entire** Cookie header on public GET/HEAD requests, and only if the request does not carry Authorization and the path does not match the operator-reviewed private-path exclusions. It also asks for lookup and stops later request-stage rules. The VCL equivalent is [`examples/vcl/public-vhost-ignore-cookies.vcl`](../examples/vcl/public-vhost-ignore-cookies.vcl). The normal request/response eligibility guards still apply; no shared-cache use of private/no-store or Set-Cookie responses is authorized. The issuing application's host-only `Set-Cookie` is preferable whenever possible. The original cookie's Domain is not transmitted in HTTP Cookie and cannot be inferred; this is a broad, high-impact opt-in rule, not an automatic safe way to discard only parent-domain cookies.
The **Vhost: remove selected parent-domain cookies** graphical rule is available only in local Vhost/Docker Vhost editors, inserted disabled. It uses the **Remove only named cookies** action and an operator-edited exact list, not `Strip cookies` / whole-header removal. It applies to GET/HEAD without Authorization and outside example private paths, does **not** return(hash) and does **not** stop later request rules. The equivalent RustProxy-specific VCL `remove_req_cookies("cookie_name");` is imported as `remove_named_cookies`. When a request has parent and session cookies, the session remains; later CDN's `bypass remaining cookies` or RustProxy's default request-cookie guard prevents shared-cache reuse. The operator must verify that the listed name is never used by this Vhost; `Cookie` does not carry the originating Domain. The old whole-header public-Vhost template is no longer offered; remove any already-saved unsafe copy manually.
### Included opt-in CDN cookie policy
+25 -24
View File
@@ -31,8 +31,8 @@ Read together with [VCL compatibility](VCL.md) and the [supported/unsupported ca
| CMS articles or a public catalog | [Public catalog](#2-public-catalog-with-explicit-short-ttl) | Cache genuinely shared 200 GETs, set TTL/grace | Force storage of `private`, `Set-Cookie` or 404 |
| Public JSON endpoint for prices/stock | [Public JSON API](#3-public-get-json-api) | Short-lived shared cache | Cache credentialed/private API responses |
| Admin, login, checkout, user dashboard | [Private routes](#1-exclude-private-routes-and-unsafe-methods) | Bypass shared cache | Replace ACL, OIDC, Basic Auth, app permissions |
| Cookies inherited from a parent domain on a **fully public** Vhost | [Public Vhost inherited cookies](#12-public-vhost-inherited-cookies-opt-in) | Remove **all** Cookie for eligible GET/HEAD after operator review | Detect which cookies came from a parent domain; guarantee safe login/personalization routes |
| Cloudflare/Akamai technical cookies | [CDN cookie allowlist](#4-cdn-technical-cookies-without-dropping-sessions) | Strip an **entire** allowlisted Cookie header | Partially delete one Cookie from a mixed list |
| Cookies set broadly by a parent domain | [Selective parent cookie removal](#12-parent-domain-cookies-remove-selected-names-opt-in) | Remove only **verified exact cookie names**, leaving application sessions intact | Infer which Domain set them; safely delete an overlapping session cookie name |
| Cloudflare/Akamai technical cookies | [CDN cookie allowlist](#4-cdn-technical-cookies-without-dropping-sessions) | Strip an **entire** CDN-only Cookie header; separate from parent cookie rule | Treat unknown or session cookies as CDN cookies |
| Public CSS, JS, fonts, images | [Static assets](#5-static-assets-and-vary-cookie) + native static settings | Strip request Cookie if proven safe; optional **conditional** `Vary: Cookie` treatment | Override any other arbitrary `Vary` dimension |
| Multilingual catalog | [Language variants](#6-language-specific-representations) | Preserve origin `Vary: Accept-Language` and separate variants | Automatically translate or change language |
| Low-cardinality public A/B content | [A/B variants](#7-low-cardinality-public-ab-variants) | Add internal header dimension via `vcl_hash` | Write `Vary` for downstream caches |
@@ -403,38 +403,37 @@ sub vcl_backend_response {
}
```
### 12. Public Vhost: inherited cookies (opt-in)
### 12. Parent-domain cookies: remove selected names (opt-in)
**Goal:** Keep cache working on a completely public site when a browser includes unrelated cookies set with `Domain=.example.test` by another host. This is generic for any hostname; **it cannot detect the cookie's original Domain**, which is not part of the HTTP `Cookie` request header.
**Goal:** A subdomain receives an unrelated, verified cookie set by a parent domain. Remove only this cookie's *name*, keeping any session/CSRF/authentication cookies for later `BYPASS` rules. The HTTP Cookie request header **does not identify the issuing Domain**. The recommended long-term fix is a host-only `Set-Cookie` at the issuing app.
**Expected traffic:** `GET /catalog`, `Cookie: parent_session=x; analytics=y` → Cookie stripped before cache lookup and before origin forwarding. The origin serves its anonymous public representation; an eligible repeat GET may HIT. `GET /account` or a request with `Authorization` keeps its cookies and follows normal bypass/auth policies. POST is unaffected.
**Expected traffic:** `GET /catalog` with `parent_marketing=1; app_session=abc` → remove `parent_marketing`, preserve `app_session`, and then the separate CDN **remaining cookies** rule causes `BYPASS`. With only `parent_marketing=1`, RustProxy may cache eligible anonymous content. With `parent_marketing=1; __cf_bm=2`, the parent rule removes the first and the separate CDN rule removes the second; this allows normal cache lookup. POST, protected paths and Authorization are unaffected.
**Prerequisites:** Use the per-Vhost cache rule editor, confirm that the *entire eligible area* is public for guests and logged-in users, and extend the excluded path regex to cover **all** private routes of the application. The graphical template is **disabled by default** until manually enabled. Avoid installing it globally or after existing terminal Cookie `pass` rules. The safest fix is often to remove the broad `Domain` attribute from `Set-Cookie` at the issuing application so browsers no longer send unrelated cookies to siblings.
**Prerequisites:** On the Vhost, add **Vhost: remove selected parent-domain cookies**, replace `REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME` with the actual verified cookie names in **Remove only named cookies**, review sensitive paths, then enable. Keep the CDN template as its **own group of rules**, with this new rule above `CDN: remove ONLY technical cookies` and `CDN: bypass remaining cookies`. Do not enable a previous **ignore ALL inherited cookies** rule: it could strip login sessions and force cache lookup. Removing that old rule from existing saved configurations is manual.
**Caveat:** This deliberately removes **every** cookie on the allowed public pages, not just analytics or inherited cookies. It can break logins, preferences, locale choice, cart, stickiness or security challenge behavior, and may serve anonymous content to a logged-in user. Never apply it to personalized content. It does not rewrite origin `Vary: Cookie`, `Set-Cookie` or `Cache-Control` and does not bypass RustProxy response privacy checks. Use [`docs/CACHE.md`](CACHE.md#inherited-cookies-on-public-vhosts-opt-in-disabled-by-default) for configuration and risk details.
**Caveat:** A cookie name may be shared by both the parent and the application; if so, do not strip it by name. This is a RustProxy-specific VCL extension rather than standard Varnish VCL. Origin privacy guards, `Set-Cookie`, and `Vary` remain active. See [Cache](CACHE.md#parent-domain-cookies-opt-in-per-vhost-name-filtering).
Source: [`examples/vcl/public-vhost-ignore-cookies.vcl`](../examples/vcl/public-vhost-ignore-cookies.vcl).
Source: [`examples/vcl/public-vhost-remove-parent-cookies.vcl`](../examples/vcl/public-vhost-remove-parent-cookies.vcl).
```vcl
// 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.
// Opt-in Vhost-only rule, SEPARATE from the CDN technical-cookie template.
// RustProxy VCL extension: remove_req_cookies() is NOT standard Varnish VCL.
// Replace REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME with exact, verified names
// that this Vhost NEVER uses for login, user state, language, cart, etc.
// Cookie headers do NOT reveal Domain; a name may also belong to this Vhost.
// Never list a session cookie that could be valid for this Vhost.
//
// 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.
// Install ABOVE "CDN: remove ONLY technical cookies" and
// "CDN: bypass remaining cookies", which must stay as separate rules.
// DO NOT use the old strip-all inherited-cookie rule in parallel.
// This rule has no return(hash): remaining cookies and sessions still pass
// through the CDN/normal cache safety checks.
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);
remove_req_cookies("REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME");
}
}
```
@@ -460,9 +459,11 @@ The outcomes below describe **decision paths**, not a guaranteed X-Cache label:
| `Cookie: __cf_bm=a; cf_clearance=b` | CDN cookie allowlist | Strip whole Cookie header | Only exact allowlisted cookie names pass. |
| `Cookie: __cf_bm=a; session=b` | CDN cookie allowlist | PASS | Even one non-allowlisted name prevents removal. |
| Two physical Cookie fields, one technical and one session | CDN cookie allowlist | PASS | Patched matcher examines combined cookie values. |
| `GET /catalog`, Cookie from parent domain | Public-Vhost opt-in | Strip all Cookie; eligible | Only on verified cookie-independent pages with reviewed exclusions. |
| `GET /account`, parent-domain Cookie | Public-Vhost opt-in | Ordinary bypass/auth rules | Protected-path guard leaves Cookie untouched. |
| `GET /catalog`, Cookie plus Authorization | Public-Vhost opt-in | Native auth/bypass | The template does not remove Cookie with Authorization. |
| `GET /catalog`, `parent_marketing=a` (listed) | Parent-name template | Remove only listed cookie; eligible | The operator must verify the name is not used for app sessions. |
| `parent_marketing=a; __cf_bm=b` | Parent-name + separate CDN templates | Both removed in order; eligible | Keep the parent rule before the CDN remaining-cookie bypass. |
| `parent_marketing=a; app_session=b` | Parent-name + separate CDN templates | Preserve `app_session`; BYPASS | Never force lookup for remaining unknown/session cookies. |
| `GET /account`, parent-domain Cookie | Parent-name template | Ordinary bypass/auth rules | Protected-path guard leaves Cookie untouched. |
| `GET /catalog`, Cookie plus Authorization | Parent-name template | Native auth/bypass | The template does not remove Cookie with Authorization. |
| `GET /assets/site.css`, arbitrary Cookie | Public static | Strip Cookie **if verified safe** | Separate native `Vary: Cookie` setting has additional conditions. |
| `GET /assets/user-avatar.png`, Cookie | Do **not** use static bypass | PASS recommended | Do not remove session personalization merely due to extension. |
| `GET /experiment`, `X-Experiment: A` | A/B variants | Eligible A partition | Origin must emit downstream `Vary: X-Experiment`. |