v0.39.2
This commit is contained in:
1 parent
d455028de3
commit
5b2eaaff61
36 files changed
+2544
-102
No files matched your search
+68
-3
@@ -119,13 +119,78 @@ With the policy enabled, the middle request stays `HIT` if the entry is fresh. C
|
||||
|
||||
In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes and unsafe force targets each place the enable/override checkbox immediately above the associated multiline list. The fields are disabled while their individual override is off; their saved values and cache policy are unchanged. Never enable unsafe forced caching for personalized responses.
|
||||
|
||||
## Cache decision precedence, explicit `pass` and public static assets
|
||||
|
||||
**Applies to RustProxy 0.39.2.** Every reason that keeps a request away from the HOT/COLD cache is classified by one central decision (`src/cache/policy/decision.rs`), used by live traffic and by **Test a request**. Reasons are evaluated strongest first:
|
||||
|
||||
| # | Source | Examples (`X-Cache-Reason`) | Can a static-file option override it? |
|
||||
|---|---|---|---|
|
||||
| 1 | **Security** | `admin_control_plane`, `basic_auth`, auth provider id (`tinyauth`, `oidc`, …), `sticky_cookie`, `request_authorization` | Never |
|
||||
| 2 | **Configuration** | `cache_disabled`, `route_disabled`, `request_upgrade` | Never |
|
||||
| 3 | **Explicit VCL `pass`** (`return(pass)`, action `pass`) | `cache_rule` | Never |
|
||||
| 4 | **VCL Cookie guard** (`return(cookie_pass)`, action `cookie_pass`) | `cache_rule_cookie` | Yes, for public static assets only (below) |
|
||||
| 5 | **Default request policy** | `request_cookie`, `request_method`, `request_body`, `path_excluded`, `query_excluded`, `request_no_store`, … | `request_cookie` only, for configured static extensions (existing behavior) |
|
||||
| 6 | **Backend response** | `response_status`, `response_set_cookie`, `response_cache_control`, `response_vary`, `response_vary_cookie`, `response_static_not_public`, `response_static_dynamic`, … | Never |
|
||||
|
||||
### `pass` versus `cookie_pass`
|
||||
|
||||
- **`pass`** is an explicit, absolute bypass. RustProxy never relaxes it, whatever the resource type or the global options. Existing rules and imported `return(pass)` keep exactly this meaning; there is no automatic conversion.
|
||||
- **`cookie_pass`** is a *Cookie/session guard*: "bypass because this request carries (session) cookies". For pages, HTML, APIs and every other non-static request it behaves exactly like `pass`. A `cookie_pass` rule must have at least one non-negated Cookie condition (the `cookie` field or the `Cookie` request header); other bypass reasons belong in a separate `pass` rule. In VCL it is written `return(cookie_pass);` — a **RustProxy extension** (stock Varnish only knows `return(pass)`).
|
||||
- The session templates (**Any Cookie**, **Common session cookies**, WordPress/WooCommerce cookies, Django, Laravel/PHP, Auth.js, ASP.NET, Drupal) and **CDN: bypass remaining cookies** now insert `cookie_pass`. Path, method, Authorization, preview, checkout, webhook and other guards still insert `pass`. WordPress and WooCommerce now insert two rules (explicit path `pass` + Cookie guard) instead of one mixed *any* rule.
|
||||
|
||||
### Public static assets with a session cookie
|
||||
|
||||
Before this change a logged-in browser got `BYPASS / cache_rule` for every CSS, JS, image and font, because the session rule ran first and the static-file options never got a chance to apply. Now, with **Settings → Cache → Ignore request cookies for static files** on (default), a `cookie_pass` bypass is relaxed **only if all** of the following hold:
|
||||
|
||||
1. the winning request decision is a `cookie_pass` guard, not `pass`;
|
||||
2. GET or HEAD, no `Authorization`, and a `Cookie` header is present;
|
||||
3. the URL path ends in one of the configured static extensions (case-insensitive; the query string is ignored for this test and remains part of the cache key);
|
||||
4. evaluating the rules **without any Cookie guard** gives no `pass` — so an explicit `pass` placed after a terminal Cookie guard (for example a `preview` cookie or `/admin` path rule) still wins;
|
||||
5. evaluating the rules **without the Cookie header** gives no `pass` — the same URL is also cacheable for an anonymous client.
|
||||
|
||||
The relaxed request then follows the normal static-cookie policy: Cookie is excluded from the cache key, so logged-in and anonymous clients share one object; header, cookie and query edits of the *non-guard* rules (for example tracking-parameter stripping) apply as for any other client, and `hash_cookie` / `hash_header` variants keep partitioning the key. The first relaxed MISS is reported as `cache_miss_static_cookie`. Nothing has to be added to each session rule.
|
||||
|
||||
The extension is only a **candidate** signal. The browser's Cookie is still forwarded to the backend on a MISS, so the reply is stored only when it is **explicitly shareable**. This *shared-static guard* runs on the original backend headers, **before** response rules such as `strip_set_cookie` or `ignore_cache_control`, for every static fill whose Cookie was ignored in the key:
|
||||
|
||||
| Backend reply | Result |
|
||||
|---|---|
|
||||
| Status other than 200 | not stored (`response_status`) |
|
||||
| `Set-Cookie` (even if a rule later strips it) | not stored (`response_set_cookie`) |
|
||||
| `Cache-Control: private`, `no-store` or `must-understand` (even with `ignore_cache_control`) | not stored (`response_cache_control`) |
|
||||
| `Vary: *` or `Vary: Authorization` | not stored (`response_vary`) |
|
||||
| `Content-Type: text/html` or `application/xhtml+xml` (SPA fallbacks, `/index.php/x.css`, error pages served as 200) | not stored (`response_static_dynamic`) |
|
||||
| No explicit freshness: none of `public`, `s-maxage`, `max-age>0`, a future `Expires` (heuristic `Last-Modified`, `default_ttl_seconds` and rule TTLs do not count) | not stored (`response_static_not_public`) |
|
||||
| `Vary: Cookie` | stored without the Cookie dimension only with **Ignore Vary: Cookie for public static assets** and `Cache-Control: public` (existing rule), otherwise `response_vary_cookie` |
|
||||
|
||||
When the guard refuses storage the client still receives its own response (`X-Cache: MISS`), and the next client goes to the origin. Proactive refresh of such shared objects is sent **without** the client's Cookie.
|
||||
|
||||
Disable **Ignore request cookies for static files** (globally or per Vhost) to restore the previous behavior exactly: `cookie_pass` then always bypasses, and the built-in policy reports `request_cookie`.
|
||||
|
||||
### Diagnostics
|
||||
|
||||
`X-Cache`, `X-Cache-Reason` and `Cache-Status` keep their names and formats; only new reason codes were added (`cache_rule_cookie`, `cache_miss_static_cookie`, `response_static_not_public`, `response_static_dynamic`). The source of a BYPASS can be read directly from the reason code using the precedence table above. **Test a request** additionally returns `reason_class` (`security`, `configuration`, `vcl_rule`, `vcl_cookie_guard`, `cookie`, `request_policy`, `response`, `cache`), `static_cookie_relaxed` and `shared_static_check`, and shows them in the panel.
|
||||
|
||||
### Migrating existing rules
|
||||
|
||||
- Saved rules are not changed. A `pass` rule that depends only on cookies keeps bypassing static files.
|
||||
- In the rules editor such a rule shows a hint and a **Convert to Cookie guard** button (only for request rules whose conditions are Cookie conditions, optionally combined with a method condition). Review, convert and save; no cache purge is needed because the change only allows *new* public objects.
|
||||
- For imported VCL replace `return(pass);` with `return(cookie_pass);` in Cookie/session branches only.
|
||||
- Keep private resources protected by an explicit `pass` (path rules, **Private account routes**, `cache.bypass_prefixes`) or by `Cache-Control: private` / `no-store` at the origin. A Cookie guard alone does not protect `/account/avatar.png` if the origin labels it public.
|
||||
- **Downgrade:** RustProxy 0.39.1 and older reject the unknown `cookie_pass` action when loading the configuration. Convert `cookie_pass` rules back to `pass` before installing an older binary.
|
||||
|
||||
### Limitations
|
||||
|
||||
- The decision trusts the origin's explicit public freshness for a Cookie-bearing fill. An origin that personalizes a `.css`/`.js`/image body and still sends `public` or `max-age` is misconfigured and would be shared; fix such resources with `private`/`no-store`, a path `pass` rule or `bypass_prefixes`.
|
||||
- Only statics fetched **with** a Cookie need explicit freshness; objects filled by anonymous clients follow the ordinary cache policy and are then served to logged-in clients as well.
|
||||
- Cache rules, including Cookie guards, do not apply to embedded Web Server sources (see [Web Server](WEB_SERVER.md)).
|
||||
|
||||
## Cache rules (VCL-style)
|
||||
|
||||
**Settings → Cache → Rules** holds global rules; **Vhosts → Cache → Cache rules for this vhost** holds rules for one vhost. They are built graphically ("If … Then …") and replace the most common Varnish VCL snippets without a scripting language.
|
||||
|
||||
| Stage | VCL equivalent | Conditions | Actions |
|
||||
|---|---|---|---|
|
||||
| Request | `vcl_recv`, `vcl_hash` | host, URL, path, extension, method, query parameter, request header, cookie, client IP | bypass cache (`pass`), explicit lookup (`hash`), remove cookies (all or all except listed), remove query parameters (list with `*`, or keep only listed), set/remove **safe request headers**, add a header or cookie value to the cache key |
|
||||
| Request | `vcl_recv`, `vcl_hash` | host, URL, path, extension, method, query parameter, request header, cookie, client IP | bypass cache (`pass`), Cookie/session guard (`cookie_pass`, see [precedence](#cache-decision-precedence-explicit-pass-and-public-static-assets)), explicit lookup (`hash`), remove cookies (all or all except listed), remove query parameters (list with `*`, or keep only listed), set/remove **safe request headers**, add a header or cookie value to the cache key |
|
||||
| Backend response | `vcl_backend_response` | the request conditions plus status (`200`, `4xx`, `500-599`), Content-Type, response header | set TTL, set grace, do not store or **undo a rule-imposed do-not-store**, ignore backend `Cache-Control`/`Expires`, remove `Set-Cookie`, set/remove permitted backend response headers |
|
||||
| Deliver | `vcl_deliver` | the request and response conditions | set a response header, set it only if the response lacks it, or remove it |
|
||||
|
||||
@@ -144,7 +209,7 @@ In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes a
|
||||
|
||||
- Reuse is scoped by frontend scheme, Host, exact client URL, Vhost/content policy and eligible `Vary` dimensions. HTTP and HTTPS objects do not cross-share.
|
||||
- GET and suitable HEAD requests may reuse a full object; changing request methods do not silently invalidate all cached GET results.
|
||||
- Authorization, dynamic cookies, `Set-Cookie`, sticky-affinity cookies, Tinyauth and other private signals normally cause **BYPASS**. The static-extension exception may ignore `Vary: Cookie` only if the explicitly public response is otherwise safe to store and the global/vhost option is on. It never overrides `private`, `no-store` or `Set-Cookie`; the origin must guarantee that the complete asset response is not session-dependent.
|
||||
- Authorization, dynamic cookies, `Set-Cookie`, sticky-affinity cookies, Tinyauth and other private signals normally cause **BYPASS**. The static-extension exception may ignore `Vary: Cookie` only if the explicitly public response is otherwise safe to store and the global/vhost option is on. It never overrides `private`, `no-store` or `Set-Cookie`; the origin must guarantee that the complete asset response is not session-dependent. A static fill fetched with a Cookie must also pass the [shared-static guard](#public-static-assets-with-a-session-cookie).
|
||||
- Only status **200 OK** responses can be stored in HOT/COLD. A cache-rule `ttl` targeting `404`, `301` or `302` cannot override this storage restriction; the older 404 TTL rule template was removed because it never produced HIT. Other response sizes, TTL, unsupported metadata, range/conditional semantics and request/client cache directives can prevent fill or require validation.
|
||||
- A Web Service selected as a Vhost source uses the same cache policy for eligible local files. File changes can be checked with `ETag` / `Last-Modified`; a 304 validation may refresh a stored body without downloading it again.
|
||||
|
||||
@@ -169,7 +234,7 @@ for n in 1 2 3; do
|
||||
done
|
||||
```
|
||||
|
||||
Look for cache reason labels including `request_cookie`, `request_authorization`, `response_cache_control`, `route_disabled` and `cache_hit` when diagnostic headers are enabled. A `MISS` alone does not prove the object was admitted to HOT/COLD.
|
||||
Look for cache reason labels including `request_cookie`, `request_authorization`, `cache_rule` (explicit VCL pass), `cache_rule_cookie` (VCL Cookie guard), `response_cache_control`, `response_static_not_public`, `route_disabled` and `cache_hit` when diagnostic headers are enabled; the [precedence table](#cache-decision-precedence-explicit-pass-and-public-static-assets) maps each code to its source. A `MISS` alone does not prove the object was admitted to HOT/COLD.
|
||||
|
||||
### Browser differs from curl (HTML, cookies, reloads)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 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.
|
||||
**Applies to RustProxy 0.39.2.** 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).
|
||||
|
||||
@@ -20,8 +20,8 @@ A template is **On** if its generated rule(s) are enabled when inserted; **Off**
|
||||
|---|---|---|---|
|
||||
| **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. |
|
||||
| **Any Cookie** (`cookiepass`) | 1 request, **On** | Any `Cookie` header exists -> `cookie_pass` (Cookie guard: BYPASS for pages; public static assets may still be cached, see below). | 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` -> `cookie_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. |
|
||||
@@ -38,7 +38,7 @@ These templates are **cache protections, not authentication or authorization**.
|
||||
|
||||
## 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.
|
||||
All seven insert **request-stage rules, enabled by default**. Cookie triggers use `cookie_pass` (Cookie/session guard); path triggers use an explicit `pass`, so WordPress and WooCommerce insert two rules. They **retain** cookies and forward them to the backend; none rewrites a session cookie.
|
||||
|
||||
| Template (internal key) | Trigger | Use and adjustments |
|
||||
|---|---|---|
|
||||
@@ -56,7 +56,7 @@ A framework template recognizes only the listed paths or cookie names. Where a s
|
||||
|
||||
| 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. |
|
||||
| **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 `cookie_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 selected exact cookie names or trailing-`*` prefixes** entered by the operator; no forced cache lookup and no `stop`. | Replace `REPLACE_WITH_VERIFIED_PARENT_COOKIE_NAME` with verified names or prefixes (e.g. `SESS*` for an unrelated Drupal 6 parent, never if this Vhost uses Drupal sessions). Other cookies remain and can trigger the CDN remaining-cookie `pass` guard. |
|
||||
|
||||
**Safe order for a Vhost using both:**
|
||||
@@ -74,7 +74,7 @@ For copyable VCL syntax, see [parent-domain cookie removal](VCL_TRAFFIC_COOKBOOK
|
||||
|
||||
## 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.
|
||||
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.2. They do not necessarily change `Cache-Control` seen by a browser.
|
||||
|
||||
| Template (internal key) | Rules / default | Match and actions | Enable only when... |
|
||||
|---|---|---|---|
|
||||
@@ -116,9 +116,13 @@ These run at the **deliver** stage. Unless accompanied by request/response rules
|
||||
|---|---|---|---|
|
||||
| **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. |
|
||||
|
||||
## `pass`, `cookie_pass` and static assets
|
||||
|
||||
Templates whose only trigger is a cookie insert `cookie_pass`. For pages it is identical to `pass`. When **Ignore request cookies for static files** is on, RustProxy can still cache a **public** CSS/JS/image/font/... for a logged-in browser, provided no explicit `pass` (path, method, Authorization, preview, ...) matches the same request and the backend reply is explicitly public. An explicit `pass` is never relaxed. Rules added from an older version keep `pass`; the editor offers **Convert to Cookie guard** for Cookie-only `pass` rules. Details: [decision precedence](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets).
|
||||
|
||||
## 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.
|
||||
- **`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` (explicit pass) or `cache_rule_cookie` (Cookie guard) while a cookie-free `curl` gets HIT. Public static assets are no longer affected when the guard is a `cookie_pass`.
|
||||
- **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.
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
|
||||
## Cache and delivery
|
||||
|
||||
- Shared HTTP cache with a memory tier (HOT) and an optional disk tier (COLD).
|
||||
- RFC 9111 freshness, validators and `Vary` with conservative header-aware normalization (known comma-list fields, language/encoding/charset qualities and media types), while preserving opaque values and quoted strings; stale-while-revalidate, stale-if-error and request coalescing. Configurable static-extension exception for cookie-independent assets: omit `Vary: Cookie` only for explicitly public cacheable responses, preserving all other Vary dimensions.
|
||||
- RFC 9111 freshness, validators and `Vary` with conservative header-aware normalization (known comma-list fields, language/encoding/charset qualities and media types), while preserving opaque values and quoted strings; stale-while-revalidate, stale-if-error and request coalescing. Configurable static-extension exception for cookie-independent assets: omit `Vary: Cookie` only for explicitly public cacheable responses, preserving all other Vary dimensions. A central [cache decision](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets) separates security bypasses, explicit VCL `pass`, Cookie/session guards (`cookie_pass`) and backend properties, so public static assets can be HIT for logged-in users without weakening explicit pass rules; Cookie-bearing static fills are stored only when the backend reply is explicitly public.
|
||||
- Varnish-compatible policy option, forced caching rules and per-location cache switches.
|
||||
- Graphical [cache rules](CACHE.md#cache-rules-vcl-style) with global and per-Vhost precedence, terminal VCL pass/hash behavior, ordered safe request-header/cookie/query rewrites, vcl_hash variants, reversible rule-only no-store decisions, backend-response header edits before cache policy, and delivery header overrides; includes a shared, responsive two-section tester in global, ordinary vhost and Docker vhost editors, a scope-aware in-panel VCL guide, and a warning-reporting VCL subset importer. The exact VCL syntax, backend vs deliver `Vary`/header mutations and safety restrictions are listed in [VCL compatibility](VCL.md); the [traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) includes ready-to-import examples and expected live request outcomes.
|
||||
- RFC 9211 `Cache-Status` and optional `X-Cache` diagnostics.
|
||||
|
||||
+4
-3
@@ -1,6 +1,6 @@
|
||||
# VCL import: supported instructions and exact effects
|
||||
|
||||
This guide describes the VCL **subset implemented by RustProxy 0.39.1**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program.
|
||||
This guide describes the VCL **subset implemented by RustProxy 0.39.2**, not the full Varnish Configuration Language. It is based on the VCL importer and cache-rule engine. Importing VCL **converts statements into graphical cache rules (which must then be saved)**; RustProxy does not execute arbitrary VCL text at request time. Unsupported instructions may be skipped with warnings or cause a parse error; they are not executed as Varnish code. **In the graphical importer, warnings pause conversion:** no rules are added until you explicitly choose **Add partial import (reviewed)**. Even after adding, you must separately save the configuration. The read-only VCL export is a human-oriented preview, **not** a lossless backup or a guaranteed re-importable VCL program.
|
||||
|
||||
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.
|
||||
|
||||
@@ -18,7 +18,8 @@ For the **complete reference to all 42 quick-rule templates** (conditions, stage
|
||||
|
||||
| Hook | Recognized VCL syntax | Actual effect and limits |
|
||||
|---|---|---|
|
||||
| `vcl_recv` | `return(pass);` | Stops request processing for the matching path; bypasses shared cache. |
|
||||
| `vcl_recv` | `return(pass);` | Stops request processing for the matching path; bypasses shared cache. An explicit pass is **never** relaxed by global cache options. |
|
||||
| `vcl_recv` | `return(cookie_pass);` | **RustProxy extension (Cookie/session guard):** like `return(pass)` for pages, but a GET/HEAD for a configured static extension may still reach the cache when **Ignore request cookies for static files** is on and no other rule would pass the same request. The branch must test `req.http.Cookie` (non-negated); otherwise the import warns and skips it. See [decision precedence](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets). |
|
||||
| `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", "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. |
|
||||
@@ -155,7 +156,7 @@ Use `unset req.http.Cookie;` only when the origin does not need **any** cookies
|
||||
- `varnish_compatible=true` and positive `cache.default_ttl_seconds` (or an explicit positive `set beresp.ttl`) may treat an otherwise eligible origin `Cache-Control: no-cache` as fresh for that TTL, **without requiring `public`**. This is RustProxy's configured override, **not** vanilla Varnish's built-in behavior.
|
||||
- `varnish_compatible=false` honors `no-cache` revalidation, including when a TTL action is present. An explicit *backend header rewrite* removing `no-cache` changes the response policy in both modes; that is a different and potentially unsafe operation.
|
||||
- Backend `private`, `no-store`, `Set-Cookie`, malformed `Vary`, unsupported status, invalid headers and size bounds still block storage **unless an administrator explicitly rewrites the affected cache-policy headers via trusted rules**. Client/request restrictions remain separate.
|
||||
- **Only HTTP 200 origin responses are storable in RustProxy 0.39.1.** Setting `beresp.ttl` for `404`, `301` or `302` does not create a negative/redirect cache. The misleading 404 TTL template was removed from the graphical editor. Deliver-stage header rules can still edit those responses without making them cacheable.
|
||||
- **Only HTTP 200 origin responses are storable in RustProxy 0.39.2.** Setting `beresp.ttl` for `404`, `301` or `302` does not create a negative/redirect cache. The misleading 404 TTL template was removed from the graphical editor. Deliver-stage header rules can still edit those responses without making them cacheable.
|
||||
- Hit-for-miss / hit-for-pass and `beresp.keep` are intentionally not imported. RustProxy already coalesces eligible misses and briefly remembers uncacheable fills for its collapse strategy, and independently retains validators for conditional revalidation. These are **not** Varnish-compatible hit-for-miss/pass objects or programmable `keep` semantics.
|
||||
|
||||
## Test an imported rule set
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# VCL capability matrix: implemented, limited and unsupported
|
||||
|
||||
**Applies to the RustProxy 0.39.1 source tree with the Docker/Cache/Traffic and CDN-template fixes.** This is an implementation inventory, not a statement of general Varnish compatibility. The authoritative implementation is `src/cache/vcl.rs` (tokenization and import), `src/cache/rules.rs` (validation and rule evaluation), and `src/cache/policy.rs` / `src/cache/lookup.rs` (shared-cache admission and lookup). See [VCL syntax and header semantics](VCL.md) for implementation details, the [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) for ready-to-import VCL and a request/response scenario matrix, and [HTTP cache](CACHE.md) for cache policy.
|
||||
**Applies to the RustProxy 0.39.2 source tree with the Docker/Cache/Traffic and CDN-template fixes.** This is an implementation inventory, not a statement of general Varnish compatibility. The authoritative implementation is `src/cache/vcl.rs` (tokenization and import), `src/cache/rules.rs` (validation and rule evaluation), and `src/cache/policy.rs` / `src/cache/lookup.rs` (shared-cache admission and lookup). See [VCL syntax and header semantics](VCL.md) for implementation details, the [VCL traffic cookbook](VCL_TRAFFIC_COOKBOOK.md) for ready-to-import VCL and a request/response scenario matrix, and [HTTP cache](CACHE.md) for cache policy.
|
||||
|
||||
## Practical examples and traffic scenarios
|
||||
|
||||
@@ -79,7 +79,8 @@ Do **not** use an unanchored regex such as `req.http.Cookie ~ "__cf_bm"` with `u
|
||||
|
||||
| Exact statement form | Status | Rule effect and restrictions |
|
||||
|---|---|---|
|
||||
| `return(pass);` | Supported | Cache bypass; terminates applicable request-stage rules and skips `vcl_hash`. |
|
||||
| `return(pass);` | Supported | Cache bypass; terminates applicable request-stage rules and skips `vcl_hash`. Never relaxed by global options. |
|
||||
| `return(cookie_pass);` | RustProxy extension | Cookie/session guard with the same termination semantics; may be relaxed only for public static assets (see [Cache](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets)). Requires a non-negated `req.http.Cookie` condition. |
|
||||
| `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, risky | Removes **every** Cookie value; never use for a session-bearing Vhost. |
|
||||
| `remove_req_cookies("exact_name", "SESS*");` | Supported, RustProxy extension | Deletes selected exact Cookie names or case-sensitive name prefixes with one trailing `*`; keeps all other cookies for later pass/cache checks. Refuses malformed Cookie fields and rejects `*` alone, prefixes shorter than 3 characters, middle wildcards and general regexes. Not stock Varnish VCL. |
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# VCL cookbook: concrete use cases and HTTP traffic scenarios
|
||||
|
||||
**Target:** RustProxy **0.39.1** with the Docker Cache/Traffic and CDN cookie patch. This guide documents the *actual importer* (`src/cache/vcl.rs`), validated cache-rule actions (`src/cache/rules.rs`), and shared-cache admission documented in [Cache](CACHE.md). It is **not** a full Varnish implementation or a promise of exact Varnish semantics.
|
||||
**Target:** RustProxy **0.39.2** with the Docker Cache/Traffic and CDN cookie patch. This guide documents the *actual importer* (`src/cache/vcl.rs`), validated cache-rule actions (`src/cache/rules.rs`), and shared-cache admission documented in [Cache](CACHE.md). It is **not** a full Varnish implementation or a promise of exact Varnish semantics.
|
||||
|
||||
Read together with [VCL compatibility](VCL.md) and the [supported/unsupported capability matrix](VCL_SUPPORT_MATRIX.md). The examples are **separate policies**, not one file that should be imported wholesale. Copy one recipe into the correct Vhost scope, then reconcile it with existing global/local rules; **never paste contradictory `return(pass)` policies together without reviewing rule order**.
|
||||
|
||||
@@ -41,7 +41,7 @@ Read together with [VCL compatibility](VCL.md) and the [supported/unsupported ca
|
||||
| Remove tracking parameters from cache identity | [Query rewrite](#10-tracking-query-normalization-restricted) or graphical Strip query | Drop approved params after URL normalization | Import arbitrary `regsub` or preserve regex URL semantics exactly |
|
||||
| Origin sets irrelevant `Set-Cookie` on public SVG | [Advanced public cookie cleanup](#11-advanced-removing-origin-set-cookie-high-risk) | Remove it before storage | Prove it was not needed for identity/session |
|
||||
| CORS responses differentiated by `Origin` | Origin's `Vary: Origin` | Keep origins separate | Safely collapse all origins into one cached response |
|
||||
| Cache error pages/redirects (`404`, `301`, `302`) | **Not supported** | No cache storage in 0.39.1 | Invent negative/redirect-cache TTL via VCL |
|
||||
| Cache error pages/redirects (`404`, `301`, `302`) | **Not supported** | No cache storage in 0.39.2 | Invent negative/redirect-cache TTL via VCL |
|
||||
| IP ranges, backend routing, purge, TLS security | Native ACL/Vhost/Cache API settings | Dedicated supported configuration | Import ACL/director/`return(purge)` as executable VCL |
|
||||
|
||||
## C. Copy-and-import VCL recipes
|
||||
@@ -182,13 +182,19 @@ sub vcl_recv {
|
||||
if (req.http.Cookie ~ "^(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*(?:;[ \t]*(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*)*$") {
|
||||
unset req.http.Cookie;
|
||||
}
|
||||
// Remaining cookies: Cookie/session guard. RustProxy extension
|
||||
// return(cookie_pass) bypasses pages like return(pass) but lets public
|
||||
// static assets use the cache when "Ignore request cookies for static
|
||||
// files" is on. In stock Varnish use return(pass) here.
|
||||
if (req.http.Cookie) {
|
||||
return(pass);
|
||||
return(cookie_pass);
|
||||
}
|
||||
return(hash);
|
||||
}
|
||||
```
|
||||
|
||||
The final guard uses `return(cookie_pass)`: logged-in pages remain `BYPASS` (`cache_rule_cookie`), while public CSS/JS/images/fonts can be shared under the static cookie policy. Use `return(pass)` there to keep the 0.39.1 behavior. See [decision precedence](CACHE.md#cache-decision-precedence-explicit-pass-and-public-static-assets).
|
||||
|
||||
### 5. Static assets and Vary: Cookie
|
||||
|
||||
**Goal:** Remove all Cookie headers **only** from independently verified public `/assets` images/fonts/scripts/styles.
|
||||
@@ -199,6 +205,8 @@ sub vcl_recv {
|
||||
|
||||
**Caveat:** VCL does **not** implement an `Ignore Vary: Cookie` instruction. Use **Static & diagnostics** options; these have additional explicit `public`/freshness/no-Set-Cookie/privacy checks. A session-aware image must not use this recipe.
|
||||
|
||||
**Without stripping cookies:** if your session guards use `return(cookie_pass)` (or the session templates), you do not need this recipe for logged-in users: with **Ignore request cookies for static files** on, public static assets reach the cache while the Cookie is still forwarded, and storage requires an explicitly public backend reply ([shared-static guard](CACHE.md#public-static-assets-with-a-session-cookie)).
|
||||
|
||||
Source: [`examples/vcl/static-assets-public.vcl`](../examples/vcl/static-assets-public.vcl).
|
||||
|
||||
```vcl
|
||||
@@ -301,7 +309,7 @@ sub vcl_hash {
|
||||
|
||||
**Prerequisites:** Use native proxy/WebSocket/stream and backend retry configuration for those separate operations.
|
||||
|
||||
**Caveat:** This is not a Varnish `vcl_backend_error`, retry, pipe or stale-if-error implementation. `500` was never eligible for 0.39.1 shared storage anyway.
|
||||
**Caveat:** This is not a Varnish `vcl_backend_error`, retry, pipe or stale-if-error implementation. `500` was never eligible for 0.39.2 shared storage anyway.
|
||||
|
||||
Source: [`examples/vcl/stream-and-errors-no-store.vcl`](../examples/vcl/stream-and-errors-no-store.vcl).
|
||||
|
||||
@@ -473,7 +481,7 @@ The outcomes below describe **decision paths**, not a guaranteed X-Cache label:
|
||||
|
||||
### D2. Origin response and `Vary`
|
||||
|
||||
| Backend sends | RustProxy 0.39.1 consequence | Safety check |
|
||||
| Backend sends | RustProxy 0.39.2 consequence | Safety check |
|
||||
|---|---|---|
|
||||
| `200`, public/fresh, no Set-Cookie, valid Vary | Potential shared-store candidate | Response must really be identical for all users. |
|
||||
| `200`, `Cache-Control: private` | Not storable without **dangerous explicit rewrite** | Never rewrite private content to public. |
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ The built-in Web Server serves local files and, optionally, passes PHP scripts t
|
||||
|
||||
1. Open **Web Server → New Web Service**. Choose an ID/name and an absolute document root readable by the RustProxy service account.
|
||||
2. Set index files (default `index.html`, `index.htm`), whether directory listing is allowed (off by default), MIME handling and download extensions.
|
||||
3. Add `try_files`, rewrites, response headers and cache rules only if your application requires them.
|
||||
3. Add `try_files`, rewrites and response headers only if your application requires them. VCL-style cache rules (including `pass` / `cookie_pass`) are **not** evaluated for Web Server sources; the static-extension Cookie option and the regular cache policy still apply to local files.
|
||||
4. Enable PHP only if you have a reachable, protected PHP-FPM endpoint; otherwise static files do not need any PHP runtime.
|
||||
5. Save, create or edit a **Vhost**, select **Web Server** as source and choose the service ID.
|
||||
6. Test index files, static assets, missing files, direct directory access, downloads and headers.
|
||||
|
||||
Reference in new issue
Block a user