v0.38.10
This commit is contained in:
1 parent
38a23e2210
commit
45b1fc04c7
36 files changed
+2123
-421
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
# RustProxy source and documentation maintenance
|
# RustProxy source and documentation maintenance
|
||||||
|
|
||||||
Current source version: **0.38.7**. The Cargo package and binary are named `rust-proxy`.
|
Current source version: **0.38.10**. The Cargo package and binary are named `rust-proxy`.
|
||||||
|
|
||||||
Before editing, read [README.md](README.md), the relevant [documentation guide](docs/README.md) and the actual code and tests. Historical release experiments are not current specifications. Use the bundled `src/admin/openapi.json` for API routes and payloads; the source implementation is authoritative for runtime behavior.
|
Before editing, read [README.md](README.md), the relevant [documentation guide](docs/README.md) and the actual code and tests. Historical release experiments are not current specifications. Use the bundled `src/admin/openapi.json` for API routes and payloads; the source implementation is authoritative for runtime behavior.
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,34 @@
|
|||||||
|
|
||||||
Release history focused on **features, settings, default behavior, compatibility and fixes**. Changes to internal code structure and preliminary performance experiments are intentionally omitted. Historical descriptions reflect their respective releases; consult the current documentation for the settings available in the latest release.
|
Release history focused on **features, settings, default behavior, compatibility and fixes**. Changes to internal code structure and preliminary performance experiments are intentionally omitted. Historical descriptions reflect their respective releases; consult the current documentation for the settings available in the latest release.
|
||||||
|
|
||||||
|
## 0.38.10 — Cache/VCL guide and targeted rule compatibility fixes (source release)
|
||||||
|
|
||||||
|
- **Cache settings help modal:** a single in-app guide opens from Settings → Cache (header and Rules subtab). It provides concrete `Cookie`, `return(hash)`, `Vary`, `beresp`/`resp` header and TTL examples, with buttons that paste safe starting points into the *unsaved* graphical VCL importer; stage order, global/per-vhost precedence, unsupported VCL features and diagnostics. Its status line reads the current form values (including unsaved changes) and warns when storage is off, the TTL is zero or RFC mode is selected.
|
||||||
|
- **Corrected built-in help:** the compatibility-mode fallback for origin `no-cache` no longer claims to require `public`; strict RFC and the separate static-file `Vary: Cookie` requirements remain explicit. Updated both Polish and English text, the documentation and styles.
|
||||||
|
- **Targeted VCL interpreter improvements:** support `set/unset req.http.<safe-header>` in the graphical rule engine, with the result visible to subsequent rule conditions, `vcl_hash` and the forwarded origin request; preserve per-vhost precedence on header conflicts. Protected authentication, request cache control and transport headers cannot be rewritten through these actions.
|
||||||
|
- **Response storage override:** `set beresp.uncacheable = false` now reverses an earlier rule-imposed `no_store`/`uncacheable=true` assignment while leaving the origin privacy/security policy and response cache eligibility intact. Per-vhost decisions take priority over conflicting global rules.
|
||||||
|
- **Conservative VCL import:** restrict conversion of `regsuball(req.url, ...)` to recognised tracking-query removal syntax; unsupported URL rewrites emit warnings instead of silently changing unrelated parameters. Preserve supported actions next to invalid edits, flush long action blocks at the 16-action rule limit, and save zero-action terminal `return(deliver)` rules through the panel. The rule tester now shows request header edits. API rule actions were extended without changing persisted cache-object formats.
|
||||||
|
- **VCL consistency audit (same version):** the importer now tokenizes escaped quotes/backslashes and rejects unterminated comments or malformed `return`, `set`, `unset` and `hash_data` statements rather than accepting partial prefixes. Standard `hash_data(req.url)` and `hash_data(req.http.Host)` are recognized as already included in the RustProxy cache key; `hash_data` outside `vcl_hash` is warned about. Added focused regression cases.
|
||||||
|
- **Safer in-panel import and preview:** VCL conversion warnings are displayed **before** any partial rules are added; the user must explicitly accept them. Export is clearly labeled a readable approximation, not a reproducible VCL backup. Removed the ineffective 404 TTL template (storage currently supports only 200) and explained these boundaries in the Cache & VCL modal, PL/EN translations and the embedded Reader.
|
||||||
|
- **Import race hardening:** closing the VCL importer or editing its source now invalidates in-flight parse results (including edits reverted to the same text); cancelled imports cannot silently add rules after the HTTP response arrives.
|
||||||
|
- **Unified tester UI and VCL help (same version):** replaced the oversized seven-field request tester layout with compact, responsive request/backend-response sections in global Cache Rules, ordinary Vhosts and Docker vhosts. A shared guide button in both local editors opens the global Cache & VCL modal but inserts examples **only into the initiating editor**. Local path tests automatically send the draft hostname as `Host` when not given; global and local tests preserve their respective draft-rule scopes, existing global/per-vhost precedence and Ignore global rules. The panel and guides clearly distinguish rule simulation from live HTTP/HIT testing and warn about unsaved cache settings. No changes to proxy routing, API schema or stored configuration.
|
||||||
|
- **Testing status:** additional source-level Rust regression tests and an optional Playwright/Chromium smoke test for global and per-vhost UI imports were added. Browser UI and source-validation checks pass; compilation and Rust integration tests still require a Rust-enabled toolchain before production deployment.
|
||||||
|
|
||||||
|
## 0.38.9 — VCL compatibility documentation (source release)
|
||||||
|
|
||||||
|
- **Detailed VCL reference:** documented the importer's supported conditions, stages, returns, header operations, unsupported syntax and limits, including practical global/per-vhost examples and testing guidance. Added the guide to the embedded documentation Reader.
|
||||||
|
- **`Vary` semantics and header safety:** clarified how `set/unset beresp.http.Vary` changes stored variants versus `set/unset resp.http.Vary` changing only the outgoing response; explained Cookie/Authorization safety dimensions, static-asset exceptions, header protection, `Cache-Control` rewriting and removal of `Set-Cookie`.
|
||||||
|
- **Documentation-only release:** no runtime/API behavior or cache format changes. Rust compilation/runtime tests were not run in this environment.
|
||||||
|
|
||||||
|
## 0.38.8 — Varnish-compatible cache policy and VCL rule fidelity (source release)
|
||||||
|
|
||||||
|
- **Backend `no-cache` without `public`:** with `varnish_compatible=true`, positive configured fallback TTL now explicitly overrides `no-cache` for otherwise shareable responses, also without a validator. Strict mode (`false`) retains RFC revalidation semantics. With fallback TTL zero, existing ETag/Last-Modified validation remains in place. The override is a RustProxy configuration choice, **not** built-in Varnish behavior.
|
||||||
|
- **VCL Cookie `return(hash)`:** explicit lookup can override default Cookie bypass in compatible mode; earlier session-cookie `return(pass)` is terminal. Preserved request cookies partition the cache key and are added to downstream `Vary`, with unsafe proactive refresh disabled for credential-partitioned entries. Authorization, request `no-store`, backend `private`/`no-store`/`Set-Cookie` retain their guards.
|
||||||
|
- **VCL importer and engine:** request `return(hash)`/`return(lookup)` and `return(pass)`, separate `vcl_hash`, terminal returns, nested `if`/`elsif`/`else`, compound boolean guards and in-order request rewrites are handled consistently, including on cache-disabled routes without enabling storage. Unsupported VCL still produces explicit import warnings; this is not a complete Varnish VCL runtime.
|
||||||
|
- **Backend-response override semantics:** `set/unset beresp.http.<header>` for validated non-protected headers, such as `Cache-Control`, is applied before policy and to delivered responses, including cache-bypassed traffic. Header writes within one stage are ordered; local vhost edits override conflicting global rules. Cached delivery header rules now retain operation order and allow subsequent rules to inspect changed headers.
|
||||||
|
- **Panel/API:** added backend header actions to the cache-rule editor and OpenAPI; preserve imported `hash_stage` on save/export and document terminal zero-action rules. New regression tests cover cache-policy compatibility, cookie hash behavior, branch precedence, response and deliver header rewriting.
|
||||||
|
- **Verification:** source-only release; Rust compilation and runtime/protocol tests must be completed in a Rust-enabled CI/build environment before deploying.
|
||||||
|
|
||||||
## 0.38.7 — static Vary cookie option and panel consistency
|
## 0.38.7 — static Vary cookie option and panel consistency
|
||||||
|
|
||||||
- **Static `Vary: Cookie` safety (fix):** preserve the origin's `Vary: Cookie` when a public response has zero remaining freshness or requires revalidation. An otherwise storable zero-TTL response must not trigger the static-cookie override; a positive configured fallback TTL still permits it. No configuration or API change.
|
- **Static `Vary: Cookie` safety (fix):** preserve the origin's `Vary: Cookie` when a public response has zero remaining freshness or requires revalidation. An otherwise storable zero-TTL response must not trigger the static-cookie override; a positive configured fallback TTL still permits it. No configuration or API change.
|
||||||
|
|||||||
Generated
+1
-1
@@ -1943,7 +1943,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rust-proxy"
|
name = "rust-proxy"
|
||||||
version = "0.38.7"
|
version = "0.38.10"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"arc-swap",
|
"arc-swap",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "rust-proxy"
|
name = "rust-proxy"
|
||||||
version = "0.38.7"
|
version = "0.38.10"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.99.1"
|
rust-version = "1.99.1"
|
||||||
description = "RustProxy - independent reverse proxy with local administration"
|
description = "RustProxy - independent reverse proxy with local administration"
|
||||||
|
|||||||
+37
-38
@@ -1,10 +1,10 @@
|
|||||||
61bf40a0572889dc8b0dda9eae4e93e44b0de9364b3c798106c85700ffb37c23 .dockerignore
|
61bf40a0572889dc8b0dda9eae4e93e44b0de9364b3c798106c85700ffb37c23 .dockerignore
|
||||||
4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example
|
4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example
|
||||||
e76e688874828e3743d03693b1d2872b9633b4db09909673786caf30f7cfe489 .gitignore
|
e76e688874828e3743d03693b1d2872b9633b4db09909673786caf30f7cfe489 .gitignore
|
||||||
91975a03be79d1daaa117781f363f21c7383db18b2079099dc9196b7481f8ca4 AGENTS.md
|
1e1dda6551bf6caf6d0c027e266938476c03637d81d564717cc6a7b71a25ab3e AGENTS.md
|
||||||
e5c39b233d89ee97f4f97c3f6739745a148f8a620c25d19f6dabfa18ee08ee53 CHANGELOG.md
|
ae77d51d9c3162dbb994f41f00807110f256e1d7efd006533daf511b70a98102 CHANGELOG.md
|
||||||
da73d9b3e2d274d7832bdb7057f52f0927ad34ffa7b06cf246aeacf3760a2f2e Cargo.lock
|
8d48a3f6f3b0d025511e6aa0456f0d2dd36f99fb51f62508d30527b572af28bb Cargo.lock
|
||||||
e5bbc39fb1a3a7c0db48fa9be7a8edfd3382810a47c5e2aaa0765e5a92f2946c Cargo.toml
|
c01f3fc21aafd193b8d306d1c6bf93ce97cafb137b124c62a2a5f36b2089c758 Cargo.toml
|
||||||
788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile
|
788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile
|
||||||
0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE
|
0d96a4ff68ad6d4b6f1f30f713b18d5184912ba8dd389f86aa7710db079abcb0 LICENSE
|
||||||
82d1dee2fc68158f0ea73259151461e64c8b18d807cd1fecfb1ed99dc30cf5f4 README.md
|
82d1dee2fc68158f0ea73259151461e64c8b18d807cd1fecfb1ed99dc30cf5f4 README.md
|
||||||
@@ -39,15 +39,15 @@ f30c895df3d7f289f3b7c9a73969009ecf91110f59cb247daa242f68e78aa014 docker-agent/s
|
|||||||
20313df0c14a1696d099ed881b159fe854e92538a60548a1729f92babaead881 docker-agent/system.go
|
20313df0c14a1696d099ed881b159fe854e92538a60548a1729f92babaead881 docker-agent/system.go
|
||||||
188b74ec4f58da1b46d86925a67b6a590c92fb4fd7516e8d03d43871bc3b4542 docker-agent/system_test.go
|
188b74ec4f58da1b46d86925a67b6a590c92fb4fd7516e8d03d43871bc3b4542 docker-agent/system_test.go
|
||||||
c0940a4b323d71931cf2ad4ad24d58b6d6bfd49af90c6e3fc91fcbe2b4cf312f docs/ACCESS.md
|
c0940a4b323d71931cf2ad4ad24d58b6d6bfd49af90c6e3fc91fcbe2b4cf312f docs/ACCESS.md
|
||||||
2c81d5cbd2bc763783e47d4d972263f00d55bda2d06b2e0257a779d969c5c11e docs/API.md
|
d44ffd1651afe1f2059f53907736aa1b74047d54512897532d746f98f5af689b docs/API.md
|
||||||
728b15b9825f547f34c4121219784798dd046fbbdd72ece8906d0cd77e8efc64 docs/BACKUP.md
|
728b15b9825f547f34c4121219784798dd046fbbdd72ece8906d0cd77e8efc64 docs/BACKUP.md
|
||||||
67d4340c4124971dac7edba35a436b4ff843510b6bd064d685e27af972267af2 docs/CACHE.md
|
d03da7b844a28d2e8bdb72690c571f5f46ba8bb254d801aad3f2e7e64afa09d0 docs/CACHE.md
|
||||||
a64f72b95918c24938aa7268ec0a534cb0f28dd1ee0aa325b02c49f3347ccf54 docs/CERTIFICATES.md
|
a64f72b95918c24938aa7268ec0a534cb0f28dd1ee0aa325b02c49f3347ccf54 docs/CERTIFICATES.md
|
||||||
6aa83366ad45227d10ebe121ed2c4f690ebcb826939ec2b2eafb40bfd714ac69 docs/CONFIGURATION.md
|
6aa83366ad45227d10ebe121ed2c4f690ebcb826939ec2b2eafb40bfd714ac69 docs/CONFIGURATION.md
|
||||||
fec29ce846d6705eb45819d85d382f28e28a146b265feab2e4c7cce2a35e5883 docs/CUSTOM_LOCATIONS.md
|
fec29ce846d6705eb45819d85d382f28e28a146b265feab2e4c7cce2a35e5883 docs/CUSTOM_LOCATIONS.md
|
||||||
2f3e005ab01bb48b6a2d74dd8f163159f892d08c35d9ad7162e912e1d4def870 docs/DASHBOARD.md
|
2f3e005ab01bb48b6a2d74dd8f163159f892d08c35d9ad7162e912e1d4def870 docs/DASHBOARD.md
|
||||||
402fd12c8d404c469f2df390e8da96c97ac2f498d92f8fc5d82830d763aa3570 docs/DOCKER_DISCOVERY.md
|
a7cfdc1a0fb1d2aaaa194587d5f168a212b4fad6045156e84228e99358ae3195 docs/DOCKER_DISCOVERY.md
|
||||||
84d0ec89445d85c78e690513763bf2a7d16347d67680e0936a85473ed756e31d docs/FEATURES.md
|
e8d65d6afb9b857c95c918811cb48e59888c7adb4c2bf39d576a3c5953ebccae docs/FEATURES.md
|
||||||
f5835144cd2802abbcac3a36c76bdd4ec2f25fa49307facb199efec5bf9e92d3 docs/HEADLESS.md
|
f5835144cd2802abbcac3a36c76bdd4ec2f25fa49307facb199efec5bf9e92d3 docs/HEADLESS.md
|
||||||
4282602f0b814841f71282040003bec91c24611e5152b33407b76e62357f8d3a docs/INSTALL.md
|
4282602f0b814841f71282040003bec91c24611e5152b33407b76e62357f8d3a docs/INSTALL.md
|
||||||
6e37859bf0dced99d4a7db93790cb38fcd90191932827946d5223eaa4c784fce docs/LOGS.md
|
6e37859bf0dced99d4a7db93790cb38fcd90191932827946d5223eaa4c784fce docs/LOGS.md
|
||||||
@@ -55,7 +55,7 @@ f5835144cd2802abbcac3a36c76bdd4ec2f25fa49307facb199efec5bf9e92d3 docs/HEADLESS.
|
|||||||
a7717c4ab03417914805527e573ea1dfd5d35295bf7b347d0c098bda6d469850 docs/MONITORING.md
|
a7717c4ab03417914805527e573ea1dfd5d35295bf7b347d0c098bda6d469850 docs/MONITORING.md
|
||||||
6d3937088eeb67a9f690d44ebe0b6e660b68116dbf69091ac7816bdc52cec2b6 docs/PERFORMANCE.md
|
6d3937088eeb67a9f690d44ebe0b6e660b68116dbf69091ac7816bdc52cec2b6 docs/PERFORMANCE.md
|
||||||
d5894c07c68ec4230987767198434abee13b0e525842fea21bcbe752fa82742b docs/PHP_FPM.md
|
d5894c07c68ec4230987767198434abee13b0e525842fea21bcbe752fa82742b docs/PHP_FPM.md
|
||||||
856269fc0098b9a40297b5d26731fd5e81079342e7d27eedee2a08acda9e0f39 docs/README.md
|
a84096680ede9b56de31c336f14122f91f8bf3c5a1ed9a292e66eeddd4dcce9f docs/README.md
|
||||||
490a6dbe870f2b1fd4ec7816768dde6c86fa7957fc9de2d2f075e123c9222222 docs/RESPONSE_DELIVERY.md
|
490a6dbe870f2b1fd4ec7816768dde6c86fa7957fc9de2d2f075e123c9222222 docs/RESPONSE_DELIVERY.md
|
||||||
95ab4786792d5920a2e109b7d196838057f24b512a69d713fb5884dc75c84339 docs/SCREENSHOTS.md
|
95ab4786792d5920a2e109b7d196838057f24b512a69d713fb5884dc75c84339 docs/SCREENSHOTS.md
|
||||||
3a48184b36d225757fc5e2d22c629f89bfe5d4007ff087f0be0ce02a5fb04c28 docs/SECURITY.md
|
3a48184b36d225757fc5e2d22c629f89bfe5d4007ff087f0be0ce02a5fb04c28 docs/SECURITY.md
|
||||||
@@ -63,7 +63,8 @@ bbef60ff1771da9f48af812987766e1e479408873ae2f079b13f1d5c62ecc6ff docs/STREAMS.m
|
|||||||
c9c9a0b401f0565f15b834d855bfdb34edb3eab46bff03d9e0825af204d20bf8 docs/TODO.md
|
c9c9a0b401f0565f15b834d855bfdb34edb3eab46bff03d9e0825af204d20bf8 docs/TODO.md
|
||||||
978097cf53314ad573583d7176491d984b9dbb22295df2b00168a28b14184c4a docs/TRANSPORT.md
|
978097cf53314ad573583d7176491d984b9dbb22295df2b00168a28b14184c4a docs/TRANSPORT.md
|
||||||
be6e8af62a7bf958b94ec15e9e3263263e511d1d33abae4e45d114833fa52b07 docs/TROUBLESHOOTING.md
|
be6e8af62a7bf958b94ec15e9e3263263e511d1d33abae4e45d114833fa52b07 docs/TROUBLESHOOTING.md
|
||||||
5c74f08d01a59dd7fa0fd4fcca4432d80e98487ec70a09f10583e4658979054c docs/VHOSTS.md
|
1d6efc5d7d35e75a1f39eab7312a3c8a44a227df0d621ae5f947dc5d5d88e10e docs/VCL.md
|
||||||
|
1169420deeed8f2e8f3a0acfb3ffe16a3419820ba1869059e0b82bb2411e1537 docs/VHOSTS.md
|
||||||
e67928a9d044e71b681c3e52f9dd8b151d6b72f965d16d5da8b0eadde98b70e9 docs/WEB_SERVER.md
|
e67928a9d044e71b681c3e52f9dd8b151d6b72f965d16d5da8b0eadde98b70e9 docs/WEB_SERVER.md
|
||||||
42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png
|
42822b1c9801bcadb0e2d785cb91883ca2df1da141222631f153030c95f5e197 docs/images/about.png
|
||||||
deff2393a987ac7102179dc85b48baf2c4a3882291bb8c7c584d760cc497c631 docs/images/api.png
|
deff2393a987ac7102179dc85b48baf2c4a3882291bb8c7c584d760cc497c631 docs/images/api.png
|
||||||
@@ -109,8 +110,8 @@ e9cbb0224c4a3d23a6019ba557e0cd568c1ad5e1582ff1e335fb7d99b7a1055d integrations/r
|
|||||||
3f092a9ab80221eddd67be4d1a776acbc6e04c1eb6011b588280c28e83b2582f integrations/routeros-oci-build/build-routeros-oci.sh
|
3f092a9ab80221eddd67be4d1a776acbc6e04c1eb6011b588280c28e83b2582f integrations/routeros-oci-build/build-routeros-oci.sh
|
||||||
3f267cafa16006e5456ade78ee2d5fae02cc7ce747839523068ffd8d7c98798a integrations/routeros-oci-build/docker-entrypoint.sh
|
3f267cafa16006e5456ade78ee2d5fae02cc7ce747839523068ffd8d7c98798a integrations/routeros-oci-build/docker-entrypoint.sh
|
||||||
ae2ee2887fcba096d0de25edcc18faa1ffec35759274518db1bf6d6982f7176c langs/README.md
|
ae2ee2887fcba096d0de25edcc18faa1ffec35759274518db1bf6d6982f7176c langs/README.md
|
||||||
1dad7ea129ec7a78c15e1210407d13fe5ae6710313868f1221c9544a37234d66 langs/en_US.json
|
8dd0d83f0abcb18d66fb195aa233f599bf444846aaab7c3d3a48bd6bb002cc36 langs/en_US.json
|
||||||
13756f27d5d2fb77ca3e41338993f04e3d0ed7d58f8cc5b5f98e1d30568508db langs/pl_pl.json
|
85f37488fcc0d38622fc1b089ea05fdfdd238b64e8b6cc299fdaf43f03b8bda4 langs/pl_pl.json
|
||||||
8ed80f14633970899d56f4ea72684a8d4b1f2843c1c78bfacc4cbb5f7ce9ef4b make_zip.py
|
8ed80f14633970899d56f4ea72684a8d4b1f2843c1c78bfacc4cbb5f7ce9ef4b make_zip.py
|
||||||
e830d37dd1f81a4b0aa7d535f5bba69e34e433b0fd99cc8ee0b296786c32379a migrations/0002_admin.sql
|
e830d37dd1f81a4b0aa7d535f5bba69e34e433b0fd99cc8ee0b296786c32379a migrations/0002_admin.sql
|
||||||
20112cc82192098b8d602f1c4f7ca08712e9e1366c845fabb92753187c370d35 migrations/0003_certificate_renewals.sql
|
20112cc82192098b8d602f1c4f7ca08712e9e1366c845fabb92753187c370d35 migrations/0003_certificate_renewals.sql
|
||||||
@@ -168,7 +169,7 @@ b28a08ea996befe10949676f40fab5f1036a274c7d0ab1175cf5c43c59849dc3 src/admin/acce
|
|||||||
f73678bfa4c4f92779cf4e8ae2feb37419de320fb1b53111c982539d5761dbcf src/admin/alerts.rs
|
f73678bfa4c4f92779cf4e8ae2feb37419de320fb1b53111c982539d5761dbcf src/admin/alerts.rs
|
||||||
7e23e70451c6498a43f65751c5bd7a110c63e24da05f6126b38dbacb33c962ca src/admin/api_token_access.rs
|
7e23e70451c6498a43f65751c5bd7a110c63e24da05f6126b38dbacb33c962ca src/admin/api_token_access.rs
|
||||||
5f5b150bb8f51f57462e519650093354ae7b40fcb80c4380fd3391a33f4b30f2 src/admin/api_tokens.rs
|
5f5b150bb8f51f57462e519650093354ae7b40fcb80c4380fd3391a33f4b30f2 src/admin/api_tokens.rs
|
||||||
462c4c24738edd4d9000a70ef9769991325b215da09a776e0cf669d77f2dd9f1 src/admin/cache_rules.rs
|
7a9239a26d3ff7185738f515f4f19411705a0a74553b6b209b94e08dd200cdfa src/admin/cache_rules.rs
|
||||||
34e851f725e8605e3c5d9946e56ac035996f3bd9d608169cba3408060d229c9b src/admin/certificate_api.rs
|
34e851f725e8605e3c5d9946e56ac035996f3bd9d608169cba3408060d229c9b src/admin/certificate_api.rs
|
||||||
4a8b6406a44508b8ba102fef0d8309e871dbe0cbdbee1e6c8721baaca0c1aee1 src/admin/certificate_inspection_tests.rs
|
4a8b6406a44508b8ba102fef0d8309e871dbe0cbdbee1e6c8721baaca0c1aee1 src/admin/certificate_inspection_tests.rs
|
||||||
aefbef9839f9914ba05ea62bceff1463da3042b52ee851181ee39d4fbf7b91c3 src/admin/certificates.rs
|
aefbef9839f9914ba05ea62bceff1463da3042b52ee851181ee39d4fbf7b91c3 src/admin/certificates.rs
|
||||||
@@ -176,7 +177,7 @@ aefbef9839f9914ba05ea62bceff1463da3042b52ee851181ee39d4fbf7b91c3 src/admin/cert
|
|||||||
7cac90d705a201b764d283e06774744e4b358eb157a8c492357bfc21aed37543 src/admin/config_sections.rs
|
7cac90d705a201b764d283e06774744e4b358eb157a8c492357bfc21aed37543 src/admin/config_sections.rs
|
||||||
c51f725075b5c4fc3fb7fb8b8b5f73987bff698a400e8950e968068b97a77631 src/admin/dashboard_presets.rs
|
c51f725075b5c4fc3fb7fb8b8b5f73987bff698a400e8950e968068b97a77631 src/admin/dashboard_presets.rs
|
||||||
aae1ca0e70d987830bd63948d431f54302083148177c1b551565be12df7fe771 src/admin/documentation.rs
|
aae1ca0e70d987830bd63948d431f54302083148177c1b551565be12df7fe771 src/admin/documentation.rs
|
||||||
fda952396c0c06a1deb474c66a27ea12ca4a4892d8412d7d7fcd80e814dde23e src/admin/documentation/documents.rs
|
950cd7f14c061838311b0d4babfb82bc0901b918691b633bba9772b8a8dfddfb src/admin/documentation/documents.rs
|
||||||
b9c2952e3fcfca540d0ad64f2d3acc5c1f5240e707f4f23ef4d452f46fcb520f src/admin/documentation/tests.rs
|
b9c2952e3fcfca540d0ad64f2d3acc5c1f5240e707f4f23ef4d452f46fcb520f src/admin/documentation/tests.rs
|
||||||
1ce779b84aa8f47bdb3c34f83593c1f2f06d2235f0319847096cfcd035434168 src/admin/file_log_search.rs
|
1ce779b84aa8f47bdb3c34f83593c1f2f06d2235f0319847096cfcd035434168 src/admin/file_log_search.rs
|
||||||
059218501907355b22bc84e7e0c41ec72565af283f5e97170ce7707ea5874009 src/admin/file_logs.rs
|
059218501907355b22bc84e7e0c41ec72565af283f5e97170ce7707ea5874009 src/admin/file_logs.rs
|
||||||
@@ -184,7 +185,7 @@ d58a2ed83319176de4e66790ed292447c9497ae031464ec55cfe27174acb639a src/admin/file
|
|||||||
77b8c05645969834cc8a58e249a7b60a57d6c47ad1c5cd92ffa5e4a9b5a8e73c src/admin/file_logs_query.rs
|
77b8c05645969834cc8a58e249a7b60a57d6c47ad1c5cd92ffa5e4a9b5a8e73c src/admin/file_logs_query.rs
|
||||||
13f885b119b79c44cba69c67bdda5a69670d3179472487379edd0a05199486fa src/admin/logging_api.rs
|
13f885b119b79c44cba69c67bdda5a69670d3179472487379edd0a05199486fa src/admin/logging_api.rs
|
||||||
51228956c33358278ebed62941da273e1e87d0b5c5d1c40cc0d2c91aec9d7362 src/admin/mod.rs
|
51228956c33358278ebed62941da273e1e87d0b5c5d1c40cc0d2c91aec9d7362 src/admin/mod.rs
|
||||||
dd1ed3f82da04c746063583a48243675f534c93297bc362a37b229fb6d2c0960 src/admin/openapi.json
|
320d3ad9554cfd43959411cb7a84bc2a48c54acbf376b5fa084de6dca48ae5a7 src/admin/openapi.json
|
||||||
f7a356109786635dd58cba590c71c796dbf36b47f25845190c75ee5c6a9fcb86 src/admin/operations.rs
|
f7a356109786635dd58cba590c71c796dbf36b47f25845190c75ee5c6a9fcb86 src/admin/operations.rs
|
||||||
257d93a29d0bda96462bcf695aba8d0ec0f9412c379e066ec46ae8ee034e3a53 src/admin/panel_assets.rs
|
257d93a29d0bda96462bcf695aba8d0ec0f9412c379e066ec46ae8ee034e3a53 src/admin/panel_assets.rs
|
||||||
f5127855c2994d052678865df36d703b74f4a0afc633daf7718b10da18d26e37 src/admin/panel_content.rs
|
f5127855c2994d052678865df36d703b74f4a0afc633daf7718b10da18d26e37 src/admin/panel_content.rs
|
||||||
@@ -234,14 +235,14 @@ b0930110e4eb7de6826e27b5b46c47e46556449fed6dc505d42da4f5e9c20366 src/admin/web/
|
|||||||
b7ead49224a4ec67181d3f24f9d9634bd6d76756f826a4d5d993300637d1d8f3 src/admin/web/app/stream-dashboard.js
|
b7ead49224a4ec67181d3f24f9d9634bd6d76756f826a4d5d993300637d1d8f3 src/admin/web/app/stream-dashboard.js
|
||||||
7de070cc8cdde45d7e0932259299e341e25b32c9ffbd87e4fcce934d0f090de4 src/admin/web/app/web-overview.js
|
7de070cc8cdde45d7e0932259299e341e25b32c9ffbd87e4fcce934d0f090de4 src/admin/web/app/web-overview.js
|
||||||
1de54408b1a0c131fcb636f39cd4cf080d11da3188c42dd55bffbd1ef71f2322 src/admin/web/cache-panel.js
|
1de54408b1a0c131fcb636f39cd4cf080d11da3188c42dd55bffbd1ef71f2322 src/admin/web/cache-panel.js
|
||||||
a0dae04a14d19dfbf38f4600a70b1370f41c233803aa5e3c3bf9a01a468552af src/admin/web/cache-rules.js
|
cd0585403a82e7b30d56d674497ec8a6322f6662537d19be942816c0652d7f07 src/admin/web/cache-rules.js
|
||||||
6288b0a8228d828ac2e2535ace2d1aefd1c04011e789eb97f7279129874ac35c src/admin/web/certificate-api.js
|
6288b0a8228d828ac2e2535ace2d1aefd1c04011e789eb97f7279129874ac35c src/admin/web/certificate-api.js
|
||||||
f554ca7179fe4d97ae24aa004d4bc9ada5f84fc78257891933a7fed728006ef8 src/admin/web/css/00-tokens.css
|
f554ca7179fe4d97ae24aa004d4bc9ada5f84fc78257891933a7fed728006ef8 src/admin/web/css/00-tokens.css
|
||||||
f13fd5486664d9803a99e226321bc84bd571a100c105884e6c68b127071595f1 src/admin/web/css/10-base.css
|
f13fd5486664d9803a99e226321bc84bd571a100c105884e6c68b127071595f1 src/admin/web/css/10-base.css
|
||||||
e360478a3dc3a3b316cc94712480f8c5cb1f8e78e5240613deda240ac4c16abe src/admin/web/css/20-shell.css
|
e360478a3dc3a3b316cc94712480f8c5cb1f8e78e5240613deda240ac4c16abe src/admin/web/css/20-shell.css
|
||||||
0d4e3b1de575b886a8614d682a94fd43fa88a6a3ed85dfa5a5d940a622add5cb src/admin/web/css/30-overview.css
|
0d4e3b1de575b886a8614d682a94fd43fa88a6a3ed85dfa5a5d940a622add5cb src/admin/web/css/30-overview.css
|
||||||
48f4c9bf5f6d70baa1bf9b32b131c1c5c0c90f51f021e64581bb04e8e41bf864 src/admin/web/css/40-editors.css
|
46103ca55fe2fcb888a0e2ad7f53c75b8a908805c30412a994cc083bef85aefc src/admin/web/css/40-editors.css
|
||||||
00401b9a5a994f10206ca4ca2aa248e24628ca38008d24259eb8304282ed5f85 src/admin/web/css/50-settings.css
|
ae86be4089f4d64336cb054cb4283bfebff35ecfe1f47520c5e7f9a3a0b7a9a3 src/admin/web/css/50-settings.css
|
||||||
dc1fcfcd9b53b97b6683e804c45433cd53236f97b6e80fccef40884f304f986b src/admin/web/css/60-monitoring.css
|
dc1fcfcd9b53b97b6683e804c45433cd53236f97b6e80fccef40884f304f986b src/admin/web/css/60-monitoring.css
|
||||||
10099d160c4fd1ed153d085dd4267661bc1ae119594a650354a93b5dd0f60e16 src/admin/web/css/70-responsive.css
|
10099d160c4fd1ed153d085dd4267661bc1ae119594a650354a93b5dd0f60e16 src/admin/web/css/70-responsive.css
|
||||||
8009afdb04d5170687816730cc930a22fead1fe0248835ca7e8de81d6907395d src/admin/web/css/README.md
|
8009afdb04d5170687816730cc930a22fead1fe0248835ca7e8de81d6907395d src/admin/web/css/README.md
|
||||||
@@ -250,7 +251,7 @@ dc1fcfcd9b53b97b6683e804c45433cd53236f97b6e80fccef40884f304f986b src/admin/web/
|
|||||||
78bf6179f769b68d518028464697e50dea5d75e33ecb1b89d88e2c2b01e86bf2 src/admin/web/dashboard-defaults.json
|
78bf6179f769b68d518028464697e50dea5d75e33ecb1b89d88e2c2b01e86bf2 src/admin/web/dashboard-defaults.json
|
||||||
355046ecb80ce6adb73ceabd29825b0cf79ca364771070cedd5eb44760fae890 src/admin/web/dashboard-widgets.json
|
355046ecb80ce6adb73ceabd29825b0cf79ca364771070cedd5eb44760fae890 src/admin/web/dashboard-widgets.json
|
||||||
50d1ebcbaf4d0b2968da23bb943fc3f67131c5d32df3f61d23ff37aad9da5b81 src/admin/web/demo.html
|
50d1ebcbaf4d0b2968da23bb943fc3f67131c5d32df3f61d23ff37aad9da5b81 src/admin/web/demo.html
|
||||||
334306d5133e455f32b42b737d2d156dacc1c625eaad006ab4bf88a176821d1f src/admin/web/docker.js
|
155c0ba1e7cb7168e8b4c37ab7653eea84f0214645fa16d10193ec3277b50480 src/admin/web/docker.js
|
||||||
8bf5d1f4f06d6e87536d808a680bf3d3a0c90c1637df0e58da667fd22ad4782d src/admin/web/docs.css
|
8bf5d1f4f06d6e87536d808a680bf3d3a0c90c1637df0e58da667fd22ad4782d src/admin/web/docs.css
|
||||||
aeffd403fa1823df7d9fa4c48280b4033b2d15e4cb9f66608caff89290de0a52 src/admin/web/docs.html
|
aeffd403fa1823df7d9fa4c48280b4033b2d15e4cb9f66608caff89290de0a52 src/admin/web/docs.html
|
||||||
306db8db9e4d651a85e09dbc15464e7f920d7fe5bd9ec9d1d8068321eb0106ab src/admin/web/docs.js
|
306db8db9e4d651a85e09dbc15464e7f920d7fe5bd9ec9d1d8068321eb0106ab src/admin/web/docs.js
|
||||||
@@ -271,7 +272,7 @@ e6c4d91d1542d0a5b47bb8736f9539d43a6713df5a473b635519d5b7eac2eb9c src/admin/web/
|
|||||||
0a5fff35555153f59d4346933030a67b6e1a8768cee7a47cfa2fcf1a2c564f63 src/admin/web/favicon.svg
|
0a5fff35555153f59d4346933030a67b6e1a8768cee7a47cfa2fcf1a2c564f63 src/admin/web/favicon.svg
|
||||||
1430936eef78ab81db57e8e9273dd0bc7d3398c8cad39acede051852d9a728f4 src/admin/web/file-logs.js
|
1430936eef78ab81db57e8e9273dd0bc7d3398c8cad39acede051852d9a728f4 src/admin/web/file-logs.js
|
||||||
85f54ce519140a38e31fb1b3d5974585748d7162f0499aa63703c1db56334b2c src/admin/web/host404.js
|
85f54ce519140a38e31fb1b3d5974585748d7162f0499aa63703c1db56334b2c src/admin/web/host404.js
|
||||||
4709e030dcca1b3ed93b291b379d94157a3c5ea2dc637caba39842ab5552b611 src/admin/web/index.html
|
b3b9720a6737c0867596fb089d7a2462782c34dc453ffe8e94bace8c871b60a3 src/admin/web/index.html
|
||||||
c5cc91382ddcf47dcff9f422ef2f94c1ebe45362c14f119c1a55b582d71443c7 src/admin/web/integrations.js
|
c5cc91382ddcf47dcff9f422ef2f94c1ebe45362c14f119c1a55b582d71443c7 src/admin/web/integrations.js
|
||||||
7a12f020fc587205694978ab41b660e9a80487d413fbf6e34fc525eabc58308f src/admin/web/login-keys.json
|
7a12f020fc587205694978ab41b660e9a80487d413fbf6e34fc525eabc58308f src/admin/web/login-keys.json
|
||||||
ac9f667273918e18406df06cb2613c923f50a88897693a03a18f500e22dc6ec2 src/admin/web/login.html
|
ac9f667273918e18406df06cb2613c923f50a88897693a03a18f500e22dc6ec2 src/admin/web/login.html
|
||||||
@@ -281,7 +282,7 @@ c2e5f554810b8e34fb47361fb90a01073a2e332ee26d82e030956fad3ec1f83e src/admin/web/
|
|||||||
1fcbe9017bd6f32cdbdcf65fcc6f4342daf9632a5e1a97c7a3a56d76cbe87095 src/admin/web/partials/overview-metrics.html
|
1fcbe9017bd6f32cdbdcf65fcc6f4342daf9632a5e1a97c7a3a56d76cbe87095 src/admin/web/partials/overview-metrics.html
|
||||||
80d6eb03f204a90f7b140c5b053d0fd8facb350b1c96b74fa1402e2a35d4fb10 src/admin/web/prometheus-token.js
|
80d6eb03f204a90f7b140c5b053d0fd8facb350b1c96b74fa1402e2a35d4fb10 src/admin/web/prometheus-token.js
|
||||||
b2d4b67fb65c55003e516e23dd783de55b0f00278035f16589f156a4659b7a54 src/admin/web/redirects.js
|
b2d4b67fb65c55003e516e23dd783de55b0f00278035f16589f156a4659b7a54 src/admin/web/redirects.js
|
||||||
709ed3db37e73f9491c22c48bd31b55ddf41acee4ce96282f21957bba564484f src/admin/web/settings.js
|
f8c3424d17bb94f80f00a7f8f4fac7ac3c8718141e975ccf5b42cc8686a00082 src/admin/web/settings.js
|
||||||
8eadbada619b15087783dcfa0e889a81f88e78034d084c5ab616f7912b835940 src/admin/web/status_200.html
|
8eadbada619b15087783dcfa0e889a81f88e78034d084c5ab616f7912b835940 src/admin/web/status_200.html
|
||||||
6322e589c449eee6db9c3499bb5643d6261f5fc3a5d730cff12cef70d5699fa2 src/admin/web/streams.js
|
6322e589c449eee6db9c3499bb5643d6261f5fc3a5d730cff12cef70d5699fa2 src/admin/web/streams.js
|
||||||
14ef42dec556c5fa62ff4ed4d6865d28f322e8e963dc43e3a714ef9d0af12ac6 src/admin/web/system-info.js
|
14ef42dec556c5fa62ff4ed4d6865d28f322e8e963dc43e3a714ef9d0af12ac6 src/admin/web/system-info.js
|
||||||
@@ -289,7 +290,7 @@ b2d4b67fb65c55003e516e23dd783de55b0f00278035f16589f156a4659b7a54 src/admin/web/
|
|||||||
dd697c7c46e40da006b61220a90ed9579c3c08c1484a96dc746314d5b4c4f3ea src/admin/web/traffic-panel.js
|
dd697c7c46e40da006b61220a90ed9579c3c08c1484a96dc746314d5b4c4f3ea src/admin/web/traffic-panel.js
|
||||||
675ea169d4cc55fda5e291af536338b882bede1eaa6c9d5cc7dfde0779c7c4d1 src/admin/web/transform-panel.js
|
675ea169d4cc55fda5e291af536338b882bede1eaa6c9d5cc7dfde0779c7c4d1 src/admin/web/transform-panel.js
|
||||||
a49da8cd65b1db4a96ff6a4f101629d3ed036798d5f14f5d8297036fb7f6c75a src/admin/web/vhosts/core.js
|
a49da8cd65b1db4a96ff6a4f101629d3ed036798d5f14f5d8297036fb7f6c75a src/admin/web/vhosts/core.js
|
||||||
8484f15cbdf97d038c498657973ba7913ad57aaf84f90c18d4c6ff73b42be967 src/admin/web/vhosts/editor.js
|
d0d0507ee2067fa95d0c7e7e2edc4ca9cb416ce040a7bc548bd07d4fbdc94556 src/admin/web/vhosts/editor.js
|
||||||
3776f72d7051af86ac5fbdd4581040dd88a424c0c6cde789301b032b159094d8 src/admin/web/vhosts/health.js
|
3776f72d7051af86ac5fbdd4581040dd88a424c0c6cde789301b032b159094d8 src/admin/web/vhosts/health.js
|
||||||
b3239e67901f1796d7a974ade0796f2e3590ff8064628a5629b78c7f6ce2f32e src/admin/web/vhosts/protocol.js
|
b3239e67901f1796d7a974ade0796f2e3590ff8064628a5629b78c7f6ce2f32e src/admin/web/vhosts/protocol.js
|
||||||
8c3da49973c62333559b0e3588c02beb0b425c025eac5cfa82a1bb968f70d9dd src/admin/web/vhosts/rates.js
|
8c3da49973c62333559b0e3588c02beb0b425c025eac5cfa82a1bb968f70d9dd src/admin/web/vhosts/rates.js
|
||||||
@@ -357,18 +358,18 @@ ff1c3a1a3bc0d26218dcc943ef951c2a212c180bbf6e4bf1c542ffbf12a9f150 src/cache/mode
|
|||||||
37649cf245c90813ba1f25f80bdd261cb7ab31e2c19dd537234513edb4974251 src/cache/model/settings.rs
|
37649cf245c90813ba1f25f80bdd261cb7ab31e2c19dd537234513edb4974251 src/cache/model/settings.rs
|
||||||
14f3f8ae5252a2dc13fcf9556523ffb945b77ee92a5fb4939cd27e113fc61660 src/cache/model/views.rs
|
14f3f8ae5252a2dc13fcf9556523ffb945b77ee92a5fb4939cd27e113fc61660 src/cache/model/views.rs
|
||||||
e26dce02df9c043329ca164fed215d271781bce8fb03240f528331bf3df6b9d7 src/cache/policy.rs
|
e26dce02df9c043329ca164fed215d271781bce8fb03240f528331bf3df6b9d7 src/cache/policy.rs
|
||||||
70c255e15f2b8c030988a2263b0e07b5c16e7e26770c72becbcec6da4550fcd9 src/cache/policy/request.rs
|
1f74f1830beab307e6865d5691126c65eff153ce04d17e95cf478ee75df39205 src/cache/policy/request.rs
|
||||||
90360ed4b91736e02644aa64bacd92cfba10d8f657be5282eeb8f45f933a1781 src/cache/policy/response.rs
|
20d4af129be642f727f3de694abe9404210dd0210dc56124028d62c2f8dd4649 src/cache/policy/response.rs
|
||||||
12a6d5d9d6711e956391b4b952e8149658b8bf64cfcc0a4c59c281f2630a6aac src/cache/policy/scope_tests.rs
|
12a6d5d9d6711e956391b4b952e8149658b8bf64cfcc0a4c59c281f2630a6aac src/cache/policy/scope_tests.rs
|
||||||
c3a4300f7cdb6b2b7c16fbc489d49ba2451331bb4a55a2d9f618c684fd61eecb src/cache/range.rs
|
c3a4300f7cdb6b2b7c16fbc489d49ba2451331bb4a55a2d9f618c684fd61eecb src/cache/range.rs
|
||||||
a97558fb3f91d3b1d986004ea31b183d8cfb85f73cb212a3e1e6b9441a3d423a src/cache/rules.rs
|
37d077a35f34e3ed76601838ffc3a9596a452727ce7cbfc82d024fb70b6b5fa4 src/cache/rules.rs
|
||||||
e994977368ffd5cf399cc03f5cf18af450f3734072cc98ef2e3d24eae43bf2f5 src/cache/rules_tests.rs
|
3682fd3c1f2b6f8cd87e50c09b932faf07f01a668f925e0f85333aa7662a548b src/cache/rules_tests.rs
|
||||||
48344d7dcbbb220d8c16f5aa9bb88d86a6388b226bbf93d0ca92d8dfbf2c8001 src/cache/stats.rs
|
48344d7dcbbb220d8c16f5aa9bb88d86a6388b226bbf93d0ca92d8dfbf2c8001 src/cache/stats.rs
|
||||||
2981e35a7fbbc2b36214b5518f4ba97d57c1d2e01f4f375175c4b2c6be955927 src/cache/tests.rs
|
2981e35a7fbbc2b36214b5518f4ba97d57c1d2e01f4f375175c4b2c6be955927 src/cache/tests.rs
|
||||||
b969394b04859b269dcecd8958b1aab40b532709512714e9900f0ecad6b6d0c5 src/cache/tickets.rs
|
b969394b04859b269dcecd8958b1aab40b532709512714e9900f0ecad6b6d0c5 src/cache/tickets.rs
|
||||||
a1132b980833b1b4ce2bba9aa681ff255a0e2d61faaa65a316860da503ea1e27 src/cache/v022_cache_tests.rs
|
a1132b980833b1b4ce2bba9aa681ff255a0e2d61faaa65a316860da503ea1e27 src/cache/v022_cache_tests.rs
|
||||||
7e6eceaa937bd3276d9533603424d9154092d7c2a6a85fc0d4431c5870b79db1 src/cache/varnish_compatible_tests.rs
|
adac3b8de21a73f32d784b3fd2240d17309e8fce022163710e781d44ef590117 src/cache/varnish_compatible_tests.rs
|
||||||
3f56ef17d81b7dca532e5c66857119c7ee833788416e968dbbf464e562022be6 src/cache/vcl.rs
|
1e2217f77a5414309de354d5bff8a16d0388234e4c23e3cc7ff0f79430a6a8f7 src/cache/vcl.rs
|
||||||
1a2eb6684d9ea4a7e90970d936c75f7c8bbec46a4181fdf273be9bdac8eec847 src/compression/mod.rs
|
1a2eb6684d9ea4a7e90970d936c75f7c8bbec46a4181fdf273be9bdac8eec847 src/compression/mod.rs
|
||||||
8de82d9188c9c337690c6ec4afdad9fff20651c358e34602a93d8bb8c3d2489a src/compression/tests.rs
|
8de82d9188c9c337690c6ec4afdad9fff20651c358e34602a93d8bb8c3d2489a src/compression/tests.rs
|
||||||
e695079333ebdc2a6e7b3337cfabef171b3a0a01da0597b77feff70d417f833e src/config.rs
|
e695079333ebdc2a6e7b3337cfabef171b3a0a01da0597b77feff70d417f833e src/config.rs
|
||||||
@@ -455,16 +456,16 @@ f1b0254f53b1a4336bd8170ad441ba072b49a114e497b985cb20699b4e375044 src/prometheus
|
|||||||
c03cdfa8da7bb440d08ce4436e8bedaaf8dad5e489169e6bc156495029e12ad5 src/proxy/cache_helpers.rs
|
c03cdfa8da7bb440d08ce4436e8bedaaf8dad5e489169e6bc156495029e12ad5 src/proxy/cache_helpers.rs
|
||||||
2d39552aa01ce3d048560944975243d0a58ae762d838e547f5fa65007d871dc4 src/proxy/cache_http_invalidation.rs
|
2d39552aa01ce3d048560944975243d0a58ae762d838e547f5fa65007d871dc4 src/proxy/cache_http_invalidation.rs
|
||||||
a86b10ce0707b51e925e11ea14f7f40fa108a196166f62cf40007a97f9e17203 src/proxy/cache_http_invalidation_tests.rs
|
a86b10ce0707b51e925e11ea14f7f40fa108a196166f62cf40007a97f9e17203 src/proxy/cache_http_invalidation_tests.rs
|
||||||
df239d37b008691d54e257626009684310e6e3712e777094b8450579d56f732f src/proxy/cache_plan/mod.rs
|
f93a40303bc3b6645f6928c4e8795978b0554e30a75f4c9daf9fff1e2138a037 src/proxy/cache_plan/mod.rs
|
||||||
811a00b55b24638b4bf8a6bea9ed7c0ffe2a758f76bfe63a95e1d31bce1c2c9c src/proxy/cache_plan/tests.rs
|
811a00b55b24638b4bf8a6bea9ed7c0ffe2a758f76bfe63a95e1d31bce1c2c9c src/proxy/cache_plan/tests.rs
|
||||||
d6bd4aafab7b1371c31b3d22ddf949a08ea942489649ca12c7615b3b2d5a109a src/proxy/error_fallback.rs
|
d6bd4aafab7b1371c31b3d22ddf949a08ea942489649ca12c7615b3b2d5a109a src/proxy/error_fallback.rs
|
||||||
79ec6b6e378ecfe478ed779ba53e69030c4d5f06ebd6ae0092f335751db0667f src/proxy/forward/cache_fast_path_tests.rs
|
79ec6b6e378ecfe478ed779ba53e69030c4d5f06ebd6ae0092f335751db0667f src/proxy/forward/cache_fast_path_tests.rs
|
||||||
016bb2719511df1fc5c70256fd7d917b95e9b4ee6044c205537472737b1f6089 src/proxy/forward/cache_lookup.rs
|
016bb2719511df1fc5c70256fd7d917b95e9b4ee6044c205537472737b1f6089 src/proxy/forward/cache_lookup.rs
|
||||||
287012c81144d8f15af4a148ce3ca911d431bc59adff44e697567561aa372bb3 src/proxy/forward/h3_navigation_tests.rs
|
287012c81144d8f15af4a148ce3ca911d431bc59adff44e697567561aa372bb3 src/proxy/forward/h3_navigation_tests.rs
|
||||||
a2a097852d126851fc7191c2fda65764dc842745ad657b970399c1f906caf114 src/proxy/forward/response.rs
|
a2a097852d126851fc7191c2fda65764dc842745ad657b970399c1f906caf114 src/proxy/forward/response.rs
|
||||||
7ade7fe7642c38ccab876cf260e7363ed30f4e9987bd3b98ee97384e5592a6ec src/proxy/forward/route_cache.rs
|
110ef110c3da169e875c9a64cb0b43bd27ea51a9ec1e2f6339784d7c2d15a589 src/proxy/forward/route_cache.rs
|
||||||
affc2d69b026d0a0d3895670c58b4ee1767567ca4a4c4000058d4304695ebad5 src/proxy/forward/success_finish.rs
|
d48eca829f878f5b03bd4e3a50d30e2d51a7770cd662ee84d1a1e2a95a74223b src/proxy/forward/success_finish.rs
|
||||||
c16a806a2083eecf418cebe0f30e916166355cffe83652df4c2d970981738e0f src/proxy/forward/success_prepare.rs
|
65130cf9feb3cb8be9c9d798a6443c4ebadb7e0107250a4d007480ba5cb89f47 src/proxy/forward/success_prepare.rs
|
||||||
c965dba1d2639b338f3f3cfc17f760786a30abab708dfb7920ea3bc94d4d734b src/proxy/forward/upstream.rs
|
c965dba1d2639b338f3f3cfc17f760786a30abab708dfb7920ea3bc94d4d734b src/proxy/forward/upstream.rs
|
||||||
9cc1b71a86d98fbc24ce7abeb5c2a8353510267947963be74ad83312a5f7f297 src/proxy/forward/web_source.rs
|
9cc1b71a86d98fbc24ce7abeb5c2a8353510267947963be74ad83312a5f7f297 src/proxy/forward/web_source.rs
|
||||||
e41c2b327175374bfdcb78108bd4eb73e15830b669b2130b6d2edff6c40c2577 src/proxy/forward_entry.rs
|
e41c2b327175374bfdcb78108bd4eb73e15830b669b2130b6d2edff6c40c2577 src/proxy/forward_entry.rs
|
||||||
@@ -477,7 +478,7 @@ a08ee061e146cb7a08311106f73a04468c89f77b6ad05a2c623621a2ae9faf2a src/proxy/mod.
|
|||||||
92806ce1802da9b6771ece474d91a3458eba3f6ed19b0817b897e828a02e7e32 src/proxy/redirect_helpers.rs
|
92806ce1802da9b6771ece474d91a3458eba3f6ed19b0817b897e828a02e7e32 src/proxy/redirect_helpers.rs
|
||||||
de1763b89d98607e20f0f6e3c9b546483927cbe5450efc2e5634fe691fd52ad6 src/proxy/request_id/mod.rs
|
de1763b89d98607e20f0f6e3c9b546483927cbe5450efc2e5634fe691fd52ad6 src/proxy/request_id/mod.rs
|
||||||
78bbc1263bcd600527bf71acdf5af92bf186267a9084b076d1f75ad6492df659 src/proxy/request_id/tests.rs
|
78bbc1263bcd600527bf71acdf5af92bf186267a9084b076d1f75ad6492df659 src/proxy/request_id/tests.rs
|
||||||
6a00700dc04f30bb1134cce5e0b66347923f7c766f31b3d5e63159cd719e5f16 src/proxy/types.rs
|
7c676831d20f1f16a95d972b67a76261ee0e6fa839261511d0c796b86471082b src/proxy/types.rs
|
||||||
e44430c54038a7dc26f327b5d7085e965241da2ffef42c1526ebfc5168981f72 src/proxy/upstream_helpers.rs
|
e44430c54038a7dc26f327b5d7085e965241da2ffef42c1526ebfc5168981f72 src/proxy/upstream_helpers.rs
|
||||||
96d18a85beb9d9492f4d0690eefd9afad9c1c4eabc36f41b447b81861a92ed2a src/proxy/web_cache_revalidation/mod.rs
|
96d18a85beb9d9492f4d0690eefd9afad9c1c4eabc36f41b447b81861a92ed2a src/proxy/web_cache_revalidation/mod.rs
|
||||||
5522456cc85948228250feac92308d53b130c4a7af98d24f669aca4dfe6999b6 src/proxy/web_cache_revalidation/tests.rs
|
5522456cc85948228250feac92308d53b130c4a7af98d24f669aca4dfe6999b6 src/proxy/web_cache_revalidation/tests.rs
|
||||||
@@ -593,12 +594,9 @@ e5f5fbe702f66bfcbcbc1d1f3cd3d89bdbb929bb86aed94868a2a06a4b9e59e3 src/web_server
|
|||||||
9e584eb4455a18641c2c89f9e9725745c93f32877abf0f0f2fbea9e3d5ef38c3 src/web_server/security.rs
|
9e584eb4455a18641c2c89f9e9725745c93f32877abf0f0f2fbea9e3d5ef38c3 src/web_server/security.rs
|
||||||
b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs
|
b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs
|
||||||
714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs
|
714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs
|
||||||
|
7ecfc4a2b83d88e579be72abded564db7519f97fbb5790d399c73ce903829afd tests/browser/cache_rules_import_smoke.py
|
||||||
|
defef98203781970ecc18ac2d862c8660b8a379e8ba465dccc21a3b6170a30e3 tests/browser/cache_rules_tester_smoke.py
|
||||||
f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json
|
f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json
|
||||||
102b83171a6429b6375d8001d6c5294702385cd58ee55727cb657b1f3566e877 tests/panel_icons_browser.py
|
|
||||||
c4030b7d224553312012b1f25153dd3545e83de7bccff2894c0e8f7e0e84b721 tests/panel_icons_contract.js
|
|
||||||
02affd4839f177f07738500820c2a7c05086aa6d536c5fed9daaa1a7411bb667 tests/panel_interface_contract.py
|
|
||||||
47d51872ee62d1f0c4d010bdf55fdfda6997b4297c19b4484d653bd4300e2441 tests/panel_refresh_contract.js
|
|
||||||
e24a0f84f1bfc46964df865ac387d651f7b384d781cbc8f3a9a5b0b60f3d69ca tests/vhost_auth_selection.js
|
|
||||||
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 third_party/swagger-ui-5.33.1/LICENSE
|
cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 third_party/swagger-ui-5.33.1/LICENSE
|
||||||
0d20d1adef18aee3f40dd258172155521ce702ac445cb5f7b7d60ed32dad2fb2 third_party/swagger-ui-5.33.1/NOTICE
|
0d20d1adef18aee3f40dd258172155521ce702ac445cb5f7b7d60ed32dad2fb2 third_party/swagger-ui-5.33.1/NOTICE
|
||||||
2c9e148b9acd740850aa33ae52878f1ecf19cdc67f6041e2c0a7aab1e95782f2 third_party/swagger-ui-5.33.1/README.md
|
2c9e148b9acd740850aa33ae52878f1ecf19cdc67f6041e2c0a7aab1e95782f2 third_party/swagger-ui-5.33.1/README.md
|
||||||
@@ -610,6 +608,7 @@ eca68a07c2b1e45fdb8f512294f5a432db3ae5a6aec8fb200b47f155cd9a31d6 tools/README.m
|
|||||||
7c30c280d0b0a8bf855eeffab583ca34dc161255f7ef6124148aa979c17c26d3 tools/dev/memory_load.py
|
7c30c280d0b0a8bf855eeffab583ca34dc161255f7ef6124148aa979c17c26d3 tools/dev/memory_load.py
|
||||||
d1418f8e574a7390fd45a2aa879bdf5720b773162d65e295ab0350506aa5220a tools/dev/mock_auth.py
|
d1418f8e574a7390fd45a2aa879bdf5720b773162d65e295ab0350506aa5220a tools/dev/mock_auth.py
|
||||||
2d3ff92300b09ce9cecbbaaa9309b4d33160fa4b2291c9952b784e8cfb599ab5 tools/dev/mock_server.py
|
2d3ff92300b09ce9cecbbaaa9309b4d33160fa4b2291c9952b784e8cfb599ab5 tools/dev/mock_server.py
|
||||||
|
03bff3a7faceec39cbc839682577b65f44c6fa5ef265d901828503278acf14cb tools/dev/test_cache_rules_panel.js
|
||||||
c711154a9df425a56607bd88f03815ffb408213a31a2b66ed1c1c9a6301a2fc6 tools/legacy/backup.py
|
c711154a9df425a56607bd88f03815ffb408213a31a2b66ed1c1c9a6301a2fc6 tools/legacy/backup.py
|
||||||
5421082e24f3794356331157e30b428f3221a0d74c0b5d060bd4d3989e0bcf3a update.sh
|
5421082e24f3794356331157e30b428f3221a0d74c0b5d060bd4d3989e0bcf3a update.sh
|
||||||
56c702111022e1ca2c8f6b72c635c749b05936ffe6387bdb0a202691614cbc96 upgrade.sh
|
56c702111022e1ca2c8f6b72c635c749b05936ffe6387bdb0a202691614cbc96 upgrade.sh
|
||||||
+1
-1
@@ -21,7 +21,7 @@ The current bundled `src/admin/openapi.json` declares these operations (among ot
|
|||||||
| `GET /api/config/history` · `POST /api/config/history/restore` | Review/restore retained configuration snapshots. |
|
| `GET /api/config/history` · `POST /api/config/history/restore` | Review/restore retained configuration snapshots. |
|
||||||
| `GET /api/status` · `GET /api/backends` | Operational status and backend observations. |
|
| `GET /api/status` · `GET /api/backends` | Operational status and backend observations. |
|
||||||
| `GET /api/cache` · `POST /api/cache/purge` · `POST /api/cache/invalidate` | Cache observations and authenticated invalidation. `GET` supports the lightweight `view=live` polling view. |
|
| `GET /api/cache` · `POST /api/cache/purge` · `POST /api/cache/invalidate` | Cache observations and authenticated invalidation. `GET` supports the lightweight `view=live` polling view. |
|
||||||
| `GET /api/cache/rules/stats` · `GET /api/cache/rules/targets` · `POST /api/cache/rules/test` · `POST /api/cache/rules/import-vcl` | Cache rule match counters, the vhosts a rule can target (ordinary and generated Docker vhosts), simulation of saved or draft rules for a test request/response (also for Docker vhosts), and conversion of a VCL subset into rules (nothing is saved). See [Cache rules](CACHE.md#cache-rules-vcl-style). |
|
| `GET /api/cache/rules/stats` · `GET /api/cache/rules/targets` · `POST /api/cache/rules/test` · `POST /api/cache/rules/import-vcl` | Cache rule match counters, the vhosts a rule can target (ordinary and generated Docker vhosts), simulation of saved or draft rules for a test request/response (also for Docker vhosts), and conversion of a VCL subset into rules (nothing is saved). See [Cache rules](CACHE.md#cache-rules-vcl-style) and the [supported VCL import matrix](VCL.md). |
|
||||||
| `GET /api/transform` | Transform observations and resource usage. Supports the lightweight `view=live` polling view. |
|
| `GET /api/transform` | Transform observations and resource usage. Supports the lightweight `view=live` polling view. |
|
||||||
| `GET /api/logs` · `GET /api/live-logs` | Recent and streaming request logs. |
|
| `GET /api/logs` · `GET /api/live-logs` | Recent and streaming request logs. |
|
||||||
| `GET /api/file-logs` · `GET /api/file-logs/query` | Stored-log exploration. |
|
| `GET /api/file-logs` · `GET /api/file-logs/query` | Stored-log exploration. |
|
||||||
|
|||||||
+46
-10
@@ -37,14 +37,45 @@ Set **Default grace (seconds)** in Settings → Cache (default **60**, range 0..
|
|||||||
| Client `only-if-cached` | **Fresh/stale eligible HIT**, or **504** if no reusable representation; never fetch origin on MISS | Same |
|
| Client `only-if-cached` | **Fresh/stale eligible HIT**, or **504** if no reusable representation; never fetch origin on MISS | Same |
|
||||||
| Client `min-fresh`, `max-stale`, positive `max-age` | Keep constraints; an otherwise fresh object can be rejected by `min-fresh`, while eligible stale entries can be served by `max-stale` | Same |
|
| Client `min-fresh`, `max-stale`, positive `max-age` | Keep constraints; an otherwise fresh object can be rejected by `min-fresh`, while eligible stale entries can be served by `max-stale` | Same |
|
||||||
| Origin `no-cache` with `ETag`/`Last-Modified`, fallback TTL = `0` | Store for **conditional revalidation** (`304`) but never fresh-HIT without checking origin | Same |
|
| Origin `no-cache` with `ETag`/`Last-Modified`, fallback TTL = `0` | Store for **conditional revalidation** (`304`) but never fresh-HIT without checking origin | Same |
|
||||||
| Origin **`public, no-cache`** and explicit fallback TTL `> 0` | Treat the administrator's configured **Fallback TTL for public responses** as shared freshness (capped by max TTL), even when the origin has no validator; this explicitly overrides origin `no-cache` | Validator-only revalidation, no override |
|
| Origin `no-cache` (with or without `public`) and explicit fallback TTL `> 0` | Treat the administrator's configured fallback TTL as shared freshness (capped by max TTL), even when the origin has no validator; this explicitly overrides origin `no-cache` | Validator-only revalidation, no override |
|
||||||
| Origin `max-age=0` / already expired, with `stale-if-error`, a validator or client `max-stale` | Retain the expired representation; it does not become a fresh HIT. Can serve stale on an eligible error, revalidate, or honor explicit client allowance | Same |
|
| Origin `max-age=0` / already expired, with `stale-if-error`, a validator or client `max-stale` | Retain the expired representation; it does not become a fresh HIT. Can serve stale on an eligible error, revalidate, or honor explicit client allowance | Same |
|
||||||
| Origin `Surrogate-Control: no-store` | Do not store, even when a fallback TTL is configured; this is an additional compatibility-mode safeguard | Legacy response policy |
|
| Origin `Surrogate-Control: no-store` | Do not store, even when a fallback TTL is configured; this is an additional compatibility-mode safeguard | Legacy response policy |
|
||||||
| Origin `private`, `no-store`, `Set-Cookie`, invalid `Vary` | Must not enter shared cache; configured static-cookie exceptions do not override response privacy | Same |
|
| Origin `private`, `no-store`, `Set-Cookie`, invalid `Vary` | Must not enter shared cache; configured static-cookie exceptions do not override response privacy | Same |
|
||||||
| Eligible cached object after TTL | Implicit background-refresh grace up to **60 seconds by default** (configurable with `cache.varnish_grace_seconds`, `0` disables it) **only** for entries initially fresh with **no** origin `stale-while-revalidate` directive; explicit `stale-while-revalidate=0` disables implicit grace. Existing `must-revalidate` / `proxy-revalidate` restrictions still apply | No implicit grace |
|
| Eligible cached object after TTL | Implicit background-refresh grace up to **60 seconds by default** (configurable with `cache.varnish_grace_seconds`, `0` disables it) **only** for entries initially fresh with **no** origin `stale-while-revalidate` directive; explicit `stale-while-revalidate=0` disables implicit grace. Existing `must-revalidate` / `proxy-revalidate` restrictions still apply | No implicit grace |
|
||||||
| Cookies, Authorization, `Vary`, per-vhost exclusions/force, query/range restrictions, BAN/PURGE, request collapse, transforms, compression, HOT/COLD | Existing RustProxy mechanisms remain in effect | Same |
|
| Cookie requests | Bypass by default; an explicit cache `lookup` action (imported from VCL `return(hash)`) can allow a GET/HEAD with Cookie to reach cache. A matching `pass` rule wins, and retained Cookie values always partition the cache variant. | Cookie requests bypass without this VCL exception |
|
||||||
|
| Authorization, `Vary`, per-vhost exclusions/force, query/range restrictions, BAN/PURGE, request collapse, transforms, compression, HOT/COLD | Existing RustProxy mechanisms remain in effect | Same |
|
||||||
|
|
||||||
**Important:** using a positive fallback TTL to reuse an origin response marked `public, no-cache` is an **explicit administrative freshness override**. It can serve outdated content for that duration; leave fallback TTL at `0` if the backend's `no-cache` must always be honored. The fallback override applies only to responses carrying `public`, not to private/no-store/Set-Cookie responses or `Surrogate-Control: no-store`. The configured `max_ttl_seconds` still caps remaining freshness. Without fallback TTL, origin `no-cache` still requires an origin validator to be stored. An origin `max-age=0` is never made fresh merely because `stale-if-error` is present.
|
**Important:** in compatibility mode, a positive fallback TTL overrides an origin response's `no-cache` **even without `public`**. This is an explicit administrative freshness override, not Varnish's built-in handling of `no-cache` (which normally does not cache it), nor strict RFC 9111 behavior. It can serve outdated content for that duration; leave fallback TTL at `0` if the backend's `no-cache` must always be honored. Privacy barriers (`private`, `no-store`, `Set-Cookie`, `Surrogate-Control: no-store`) still apply. The configured `max_ttl_seconds` caps freshness. With fallback TTL 0, origin `no-cache` needs an origin validator to be stored for revalidation. An origin `max-age=0` is never made fresh merely because `stale-if-error` is present.
|
||||||
|
|
||||||
|
### VCL ordering and supported backend header overrides
|
||||||
|
|
||||||
|
Imported VCL is compiled into the **same rule engine** as the global and per-Vhost graphical rules. The editor discards in-flight import results if its source is changed or the importer is closed, so cancelled conversions cannot silently add obsolete rules. The import endpoint returns `warnings` for unsupported Varnish operations; do not deploy an imported rule set until those warnings are reviewed. RustProxy is not an arbitrary VCL interpreter, and `pipe`, `restart`, `purge`, `synth`, dynamic VCL expressions and custom subroutines are not equivalent to Varnish.
|
||||||
|
|
||||||
|
- `vcl_recv` runs before `vcl_hash` (the latter runs after `return(hash)`). `return(pass)` stops normal request rules. Terminal `return(deliver)` stops the relevant response/deliver stage. Supported request rewrites also reach the origin on cache-disabled routes; such routes still cannot store or serve from cache.
|
||||||
|
- `if`/`elsif`/`else`, nested guards, supported `&&`/`||`/`!` expressions and request-cookie/query edits preserve order. Later matching conditions see supported earlier mutations.
|
||||||
|
- `vcl_backend_response` supports `set/unset beresp.http.Header` for **constant valid headers**, as well as TTL, grace and uncacheable controls. Backend header changes affect both admission policy and the response delivered to the client (also on BYPASS). Hop-by-hop, `Set-Cookie`, length, Host and other protected fields cannot be assigned by general header actions; use the dedicated Set-Cookie removal action.
|
||||||
|
- `vcl_deliver` supports constant `set/unset resp.http.Header` and `return(deliver)`; graphical `default_header` provides set-if-missing. Ordered operations are reflected in evaluation and delivery.
|
||||||
|
- Per-Vhost rules are evaluated before applicable global rules. A vhost edit to a request cookie/query rewrite, response/deliver header, or request routing aspect wins over a conflicting global edit. In the same scope, later writes supersede earlier ones unless a matching rule has `stop=true` or terminal `return`.
|
||||||
|
- Credential separation remains mandatory for shared caching. `return(hash)` on a request carrying `Cookie` partitions RustProxy's cache variant by the **complete remaining Cookie**, and includes `Vary: Cookie` for downstream caches. Session cookies must be intercepted by an earlier `return(pass)` rule. Authorization never becomes shareable through this exception.
|
||||||
|
|
||||||
|
### Complete VCL support and `Vary`/header overrides
|
||||||
|
|
||||||
|
See [VCL compatibility and header overrides](VCL.md) for a statement-by-statement compatibility matrix, global/per-Vhost priority, stage timing, exact `set`/`unset` support, `Vary` behavior and protected headers. **`beresp.http.Vary` affects cache variants; `resp.http.Vary` only affects the outgoing header.** Unsetting either can break downstream cache correctness. `set/unset beresp.http.Cache-Control` changes cache admission policy, while deliver-stage header edits do not. A deliberately rewritten `private`/`no-store` header or removed `Set-Cookie` no longer protects the representation, so use these actions only for public content.
|
||||||
|
|
||||||
|
### Explicit Cookie lookup with imported VCL
|
||||||
|
|
||||||
|
Varnish defaults to `pass` on `Cookie`, but custom `return(hash)` can opt in. RustProxy's VCL importer supports this explicit opt-in in `varnish_compatible` mode only. Use an early `pass` rule for session cookies, followed by `return(hash)` for eligible requests:
|
||||||
|
|
||||||
|
```vcl
|
||||||
|
sub vcl_recv {
|
||||||
|
if (req.http.Cookie ~ "(^|; *)[sS][eE][sS][sS][iI][oO][nN][iI][dD]=") {
|
||||||
|
return (pass);
|
||||||
|
}
|
||||||
|
return (hash);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
The VCL importer supports a subset of VCL, not full Varnish runtime semantics. Imported `return(hash)` becomes a `lookup` request action. When Cookie remains on a request, RustProxy matches cache entries on that Cookie (not only the default URL key), avoiding accidental cross-user reuse; remove irrelevant tracking cookies first to improve HIT rate. `Authorization`, non-GET/HEAD methods, request `no-store`, access checks, private/no-store response headers and backend `Set-Cookie` are not overridden by this action. With compatibility disabled, the `lookup` action does not override Cookie BYPASS.
|
||||||
|
|
||||||
This is **a Varnish-inspired policy subset, not full Varnish binary/VCL compatibility**. RustProxy deliberately keeps an explicit zero-by-default fallback TTL instead of Varnish's implicit 120-second default, retains client controls beyond hard reload, enforces multi-tenant and cookie/Authorization safety rules, and does not implement hit-for-miss/hit-for-pass markers. The current compatibility-specific `Surrogate-Control` safeguard handles `no-store`; it does **not** interpret every Surrogate-Control extension or use Surrogate-Control `max-age` as a TTL override. Different VCL configurations can behave differently.
|
This is **a Varnish-inspired policy subset, not full Varnish binary/VCL compatibility**. RustProxy deliberately keeps an explicit zero-by-default fallback TTL instead of Varnish's implicit 120-second default, retains client controls beyond hard reload, enforces multi-tenant and cookie/Authorization safety rules, and does not implement hit-for-miss/hit-for-pass markers. The current compatibility-specific `Surrogate-Control` safeguard handles `no-store`; it does **not** interpret every Surrogate-Control extension or use Surrogate-Control `max-age` as a TTL override. Different VCL configurations can behave differently.
|
||||||
|
|
||||||
@@ -69,18 +100,19 @@ In **Vhosts → Cache**, overrides for static extensions, bypass path prefixes a
|
|||||||
|
|
||||||
| Stage | VCL equivalent | Conditions | Actions |
|
| 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`), remove cookies (all or all except listed), remove query parameters (list with `*`, or keep only listed), 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`), 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, ignore backend `Cache-Control`/`Expires`, remove `Set-Cookie` |
|
| 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 |
|
| Deliver | `vcl_deliver` | the request and response conditions | set a response header, set it only if the response lacks it, or remove it |
|
||||||
|
|
||||||
- Rules run top to bottom (drag to reorder). Each rule matches when all (or any) of its conditions match; a rule without conditions matches every request. *Stop evaluating later rules* ends the stage, like `return` in VCL.
|
- Rules run top to bottom (drag to reorder). Each rule matches when all (or any) of its conditions match; a rule without conditions matches every request. *Stop evaluating later rules* ends the stage, like `return` in VCL.
|
||||||
- Vhost rules run before global rules. A global rule can be limited to selected vhosts. For TTL, grace, bypass and *do not store*, the first matching rule wins: the vhost editor and the global list show which rules override others, and the tester lists every overridden action. *Ignore global cache rules* switches global rules off for that vhost.
|
- Vhost rules run before applicable global rules. A matching vhost assignment to request routing/cookie stripping/query stripping, TTL or grace overrides the same aspect in a global rule. Within the same scope later matching assignments win unless a terminal rule stops evaluation. Response and delivered header edits have per-header ownership; `stop` and imported VCL `return(...)` stop the current stage. The tester shows suppressed scalar overrides. *Ignore global cache rules* switches global rules off for that vhost.
|
||||||
- Request rules change the request like VCL does: removed cookies and query parameters are also not sent to the backend. Values added to the cache key create separate variants (for example one per `lang` cookie).
|
- Request rules change the request like VCL does: removed cookies, query parameters and safe selected request headers also affect the backend. Request-header edits are visible to subsequent rules and hashing; authorization, identity, transport and request cache policy fields are protected. Values added to the cache key create separate variants (for example one per `lang` cookie).
|
||||||
- Safeguards stay in place: only GET/HEAD without a body are cached, `Authorization`, Basic Auth, login providers and sticky sessions still bypass the cache, and a response with `Set-Cookie` is never stored unless a rule removes it. *Ignore backend Cache-Control* keeps the original header for the browser; it only changes what RustProxy stores.
|
- Safeguards stay in place: only GET/HEAD without a body are cached, `Authorization`, Basic Auth, login providers and sticky sessions still bypass the cache, and a response with `Set-Cookie` is never stored unless a rule removes it. *Ignore backend Cache-Control* keeps the original header for the browser; it only changes what RustProxy stores.
|
||||||
- **Test a request** checks the rules on screen (including unsaved edits) against a sample URL, headers, client IP and backend response, and shows the decision, cache key, TTL/grace, matched and overridden rules. **Import VCL** converts supported statements from `vcl_recv`, `vcl_hash`, `vcl_backend_response`/`vcl_fetch` and `vcl_deliver` (`if`/`elsif`/`else`, `~`, `!~`, `==`, `!=`, status comparisons, `return (pass)`, `unset req.http.Cookie`, query-parameter `regsuball` on `req.url`, `hash_data(req.http.X)`, `beresp.ttl`, `beresp.grace`, `beresp.uncacheable`, `unset beresp.http.Set-Cookie`, `set/unset resp.http.X`); everything else is listed as a warning. **Copy as VCL** shows the equivalent VCL (read-only).
|
- For the exact import syntax, warnings, `Vary` mutation semantics and header restrictions see [VCL compatibility](VCL.md).
|
||||||
|
- **Test a request** is a compact, responsive two-section tester (HTTP request / example backend response) shared by **Settings → Cache → Rules**, **Vhosts → Cache** and **Docker vhosts → Cache**. It checks rules on screen (including unsaved edits) against a sample URL, headers, client IP and backend response, and shows the decision, cache key, TTL/grace, matched and overridden rules. In global settings it tests unsaved **global** rules plus the selected vhost's *saved* rules/settings. In a vhost or Docker service editor it tests unsaved **local** rules plus the *saved* applicable global rules unless **Ignore global cache rules** is checked. This is a simulated decision, not a real HTTP request or a prediction of HIT after two requests. Other unsaved cache settings, such as the vhost TTL or the global compatibility toggle, are not submitted by the tester. For a path-only local test (e.g. `/product`), the panel supplies the current editor hostname as `Host` if the headers field does not already contain `Host`; a full URL or an explicit `Host` takes precedence. Unsaved/unpublished Docker vhosts may not yet have a saved vhost ID; the test then cannot model every saved per-vhost setting. Check the resulting host/key and rules before trusting the preview. **Import VCL** converts supported statements from `vcl_recv`, `vcl_hash`, `vcl_backend_response`/`vcl_fetch` and `vcl_deliver` (`if`/`elsif`/`else`, `~`, `!~`, `==`, `!=`, status comparisons, `return (pass)`, `unset req.http.Cookie`, safe constant `set/unset req.http.X`, restricted query-parameter `regsuball` on `req.url`, `hash_data(req.http.X)`, `beresp.ttl`, `beresp.grace`, `beresp.uncacheable = true/false`, `unset beresp.http.Set-Cookie`, `set/unset beresp.http.X` (constant values; non-protected headers), `set/unset resp.http.X`, terminal `return(hash)`/`return(lookup)`/`return(pass)`/`return(deliver)`, nested boolean guards); unsupported operations (including arbitrary URL rewrites) produce import warnings rather than guessed actions. **Copy as VCL** is a read-only **approximate preview**, not an exact round-trip or configuration backup. Imports with warnings now require explicit **Add partial import (reviewed)** before converted rules are added to the unsaved editor.
|
||||||
- Limits: 128 rules per list, 16 conditions and 16 actions per rule, regular expressions with linear-time matching. Match counters live in memory (reset on restart) and are exported as `rust_proxy_cache_rule_matches_total{origin,vhost,rule}` when the *Domains and effectiveness* metric group is enabled.
|
- Limits: 128 rules per list, 16 conditions and 16 actions per rule, regular expressions with linear-time matching. Match counters live in memory (reset on restart) and are exported as `rust_proxy_cache_rule_matches_total{origin,vhost,rule}` when the *Domains and effectiveness* metric group is enabled.
|
||||||
- Rules apply to Reverse Proxy vhosts (including Docker vhosts) while the cache is active for the route; built-in web server sources are not affected.
|
- Rules apply to Reverse Proxy vhosts (including Docker vhosts) while the cache is active for the route; built-in web server sources are not affected.
|
||||||
- **Deliver rules apply to the whole application.** Since 0.37.2 they run for every response of the vhost — also when caching is switched off for it, for bypassed requests and for misses — so they can override headers such as `Cache-Control` for browsers, or add security headers, for an entire application. *Set header if missing* (`default_header`) keeps a header the backend already sent. Templates: *Browser cache for static files (30 days)*, *No browser cache for HTML and /admin*, *Default security headers*. Request and backend-response rules still run only while the cache is active for the route.
|
- **Deliver rules apply to the whole application.** Since 0.37.2 they run for every response of the vhost — also when caching is switched off for it, for bypassed requests and for misses — so they can override headers such as `Cache-Control` for browsers, or add security headers, for an entire application. *Set header if missing* (`default_header`) keeps a header the backend already sent. Templates: *Browser cache for static files (30 days)*, *No browser cache for HTML and /admin*, *Default security headers*. Supported request rewrites and backend-response header edits can also affect normal reverse-proxy traffic on a cache-disabled route, but they do **not** enable cache storage. See [VCL stages](VCL.md#where-to-import-rule-order-and-activation) for the exact scope.
|
||||||
- Docker vhosts have their own rules too: in **Docker vhosts**, enable *Cache* for the service and open **Cache for this vhost** (default TTL and rules). The global rule vhost picker and the tester list Docker vhosts (marked *Docker*) next to ordinary vhosts; `GET /api/cache/rules/targets` returns the same list.
|
- Docker vhosts have their own rules too: in **Docker vhosts**, enable *Cache* for the service and open **Cache for this vhost** (default TTL and rules). The global rule vhost picker and the tester list Docker vhosts (marked *Docker*) next to ordinary vhosts; `GET /api/cache/rules/targets` returns the same list.
|
||||||
|
|
||||||
## Stored object rules
|
## Stored object rules
|
||||||
@@ -88,7 +120,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.
|
- 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.
|
- 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.
|
||||||
- Origin status, response size, TTL, unsupported metadata, range/conditional semantics and request/client cache directives can prevent fill or require validation.
|
- 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.
|
- 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.
|
||||||
|
|
||||||
## Freshness and diagnostics
|
## Freshness and diagnostics
|
||||||
@@ -114,6 +146,10 @@ 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`, `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.
|
||||||
|
|
||||||
|
### In-panel cache and VCL guide
|
||||||
|
|
||||||
|
Click **Cache & VCL guide** in **Settings → Cache**, **Vhosts → Cache** or a Docker service's **Cache** editor for the same interactive modal. The example-insertion target is the **editor that opened the modal** (global, ordinary vhost or Docker vhost), not always the global rules. The context badge identifies the destination, and the scope note explains which rules/settings are inherited and which are local. Opening the guide from a vhost does not save or modify global rules. It shows the **current form values** for compatibility mode, fallback TTL and grace, including a warning if the cache is disabled. The form may have unsaved changes; the modal does not apply settings. Example VCL snippets explain how `Cookie`, `Vary`, safe `req.http.*`, `beresp.http.*`, `resp.http.*`, `beresp.uncacheable = false` and `return(hash)` affect cache decisions. The **Insert into VCL importer** buttons copy a starting snippet into that editor's Rules import textarea (without importing or saving the rule) and invalidate older import previews; warnings now require explicit approval of a partial import. The guide warns that only 200 responses can be stored, and that VCL export is an approximate view. Validate the rule tester before saving. The modal explicitly lists unsupported VCL hooks and includes a short HIT/MISS/BYPASS checklist. For complete syntax, use [VCL import](VCL.md).
|
||||||
|
|
||||||
## Cache response headers and upstream diagnostics
|
## Cache response headers and upstream diagnostics
|
||||||
**RFC 9211:** `Cache-Status` is a structured list of cache hops, ordered from the origin-side cache toward the client. RustProxy **does not replace or suppress** an upstream `Cache-Status`. When **Settings → Cache → Expose Cache-Status** is enabled and RustProxy makes a cache decision, it appends its own `RustProxy` member to the existing list; multiple HTTP header fields are an equivalent wire representation of the same list. There is no `backend=hit/miss` parameter: the upstream's own members already describe its cache decisions.
|
**RFC 9211:** `Cache-Status` is a structured list of cache hops, ordered from the origin-side cache toward the client. RustProxy **does not replace or suppress** an upstream `Cache-Status`. When **Settings → Cache → Expose Cache-Status** is enabled and RustProxy makes a cache decision, it appends its own `RustProxy` member to the existing list; multiple HTTP header fields are an equivalent wire representation of the same list. There is no `backend=hit/miss` parameter: the upstream's own members already describe its cache decisions.
|
||||||
|
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ In **Docker vhosts**, select the service and set:
|
|||||||
| **Frontend listeners / certificate** | Selected through the agent defaults: automatic SNI or the agent's certificate list (see [Certificates](#certificates)); the editor shows the certificate that will be used. |
|
| **Frontend listeners / certificate** | Selected through the agent defaults: automatic SNI or the agent's certificate list (see [Certificates](#certificates)); the editor shows the certificate that will be used. |
|
||||||
| **Frontend protocols** | HTTP/1.1 is always available. Enable/disable HTTP/2 and HTTP/3 independently per Docker vhost (both enabled by default). H2/H3 require corresponding frontend listener support; switching them does not change the selected HTTP/HTTPS backend scheme. H3 disabled also removes its advertisement. |
|
| **Frontend protocols** | HTTP/1.1 is always available. Enable/disable HTTP/2 and HTTP/3 independently per Docker vhost (both enabled by default). H2/H3 require corresponding frontend listener support; switching them does not change the selected HTTP/HTTPS backend scheme. H3 disabled also removes its advertisement. |
|
||||||
| **Force HTTPS / WebSockets** | Enable only when needed and when the right frontend listeners exist. |
|
| **Force HTTPS / WebSockets** | Enable only when needed and when the right frontend listeners exist. |
|
||||||
| **Cache / compression / transforms** | Optional; obey the global limits and privacy policy of the application. With **Cache** enabled, **Cache for this vhost** sets a default TTL (empty = global default) and the same cache rules editor as an ordinary vhost (templates, VCL import/preview, tester, *Ignore global cache rules*); see [Cache rules](CACHE.md#cache-rules-vcl-style). Stored as `cache_default_ttl_seconds`, `cache_rules` and `cache_ignore_global_rules` on the assignment.
|
| **Cache / compression / transforms** | Optional; obey the global limits and privacy policy of the application. With **Cache** enabled, **Cache for this vhost** sets a default TTL (empty = global default) and the same cache rules editor as an ordinary vhost (templates, VCL import/preview, compact two-section tester, *Ignore global cache rules*). **Cache & VCL guide** opens the shared modal and inserts examples into this Docker vhost's importer, never the global editor. Tests use unsaved service rules plus saved applicable global rules, unless ignored; a path-only test uses the current service hostname as `Host` when no explicit Host is provided. Unpublished service tests may lack saved vhost settings; see [Cache rules](CACHE.md#cache-rules-vcl-style). Stored as `cache_default_ttl_seconds`, `cache_rules` and `cache_ignore_global_rules` on the assignment.
|
||||||
| **Security and access** | Everything an internet-facing app usually needs, without creating an ordinary vhost: **HTTP Basic Auth** (see below), **HTTP methods** (allow only / block listed, the same method picker as vhosts), **per-client IP rate limit** (requests per window and burst; exceeded requests get `429`), **country access** (block or allow only listed countries via GeoIP; country rules of ACL profiles also apply), **security headers** (HSTS with max-age and includeSubDomains, `X-Content-Type-Options: nosniff`, `X-Frame-Options`, `Referrer-Policy`) and **Use verified Cloudflare client IP** when the app is behind Cloudflare. The summary line of the section shows what is active. Stored as `method_policy`, `rate_limit`, `security_headers` and `cloudflare_client_ip`; unused options are not stored. Docker apps have no login of their own; to require one, publish the app through an ordinary vhost with HTTP Basic Auth, forward auth or OIDC. |
|
| **Security and access** | Everything an internet-facing app usually needs, without creating an ordinary vhost: **HTTP Basic Auth** (see below), **HTTP methods** (allow only / block listed, the same method picker as vhosts), **per-client IP rate limit** (requests per window and burst; exceeded requests get `429`), **country access** (block or allow only listed countries via GeoIP; country rules of ACL profiles also apply), **security headers** (HSTS with max-age and includeSubDomains, `X-Content-Type-Options: nosniff`, `X-Frame-Options`, `Referrer-Policy`) and **Use verified Cloudflare client IP** when the app is behind Cloudflare. The summary line of the section shows what is active. Stored as `method_policy`, `rate_limit`, `security_headers` and `cloudflare_client_ip`; unused options are not stored. Docker apps have no login of their own; to require one, publish the app through an ordinary vhost with HTTP Basic Auth, forward auth or OIDC. |
|
||||||
| **Diagnostic headers** | `Server-Timing`, the selected backend (`X-Rust-Proxy-Backend`) and the backend time, for testing; keep them off in production. For Docker publications the backend header uses `<agent-id>/<12-character-service-hash>` (for example `node1/012345abcdef`), rather than the internal `docker-node1-012345abcdef/docker` identifier. Ordinary Vhosts retain their usual backend IDs; the change affects only header presentation, not routing, logs or metrics. Stored as `timing_headers`, `backend_header`, `backend_timing_header`. |
|
| **Diagnostic headers** | `Server-Timing`, the selected backend (`X-Rust-Proxy-Backend`) and the backend time, for testing; keep them off in production. For Docker publications the backend header uses `<agent-id>/<12-character-service-hash>` (for example `node1/012345abcdef`), rather than the internal `docker-node1-012345abcdef/docker` identifier. Ordinary Vhosts retain their usual backend IDs; the change affects only header presentation, not routing, logs or metrics. Stored as `timing_headers`, `backend_header`, `backend_timing_header`. |
|
||||||
| **Health / ACL / timeouts** | **Access control** shows the agent default ACL profiles pre-selected (*Agent default in use: …*). Unchecking or changing them overrides the default for this service only; leaving them as they are keeps following the agent default. **Public vhost (no agent default ACL)** publishes the service without the agent default profiles (`inherit_acl_profiles: false`) and disables the per-app ACL; global block/allow rules still apply. Up to eight reusable ACL profiles per app; selected profiles appear as removable badges and the summary line shows the effective state. Optional inline ACL remains independently enforced. Explicit denies and country blocks beat merged allows. Test allowed and blocked clients. |
|
| **Health / ACL / timeouts** | **Access control** shows the agent default ACL profiles pre-selected (*Agent default in use: …*). Unchecking or changing them overrides the default for this service only; leaving them as they are keeps following the agent default. **Public vhost (no agent default ACL)** publishes the service without the agent default profiles (`inherit_acl_profiles: false`) and disables the per-app ACL; global block/allow rules still apply. Up to eight reusable ACL profiles per app; selected profiles appear as removable badges and the summary line shows the effective state. Optional inline ACL remains independently enforced. Explicit denies and country blocks beat merged allows. Test allowed and blocked clients. |
|
||||||
|
|||||||
+2
-1
@@ -66,13 +66,14 @@ RustProxy is a single service that combines a reverse proxy, a static/PHP web se
|
|||||||
- Shared HTTP cache with a memory tier (HOT) and an optional disk tier (COLD).
|
- 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.
|
||||||
- Varnish-compatible policy option, forced caching rules and per-location cache switches.
|
- Varnish-compatible policy option, forced caching rules and per-location cache switches.
|
||||||
- Graphical [cache rules](CACHE.md#cache-rules-vcl-style) in the spirit of VCL (bypass, cookies, query parameters, cache-key variants, TTL/grace, headers) per vhost and globally, with a request tester and VCL import.
|
- 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).
|
||||||
- RFC 9211 `Cache-Status` and optional `X-Cache` diagnostics.
|
- RFC 9211 `Cache-Status` and optional `X-Cache` diagnostics.
|
||||||
- Purge and ban from the panel, the API or HTTP PURGE/BAN from allowlisted addresses.
|
- Purge and ban from the panel, the API or HTTP PURGE/BAN from allowlisted addresses.
|
||||||
- Live compression with gzip, Brotli, Zstandard and deflate.
|
- Live compression with gzip, Brotli, Zstandard and deflate.
|
||||||
- Optional minification of JavaScript, CSS, HTML, SVG and JSON with memory budgets.
|
- Optional minification of JavaScript, CSS, HTML, SVG and JSON with memory budgets.
|
||||||
|
|
||||||

|

|
||||||
|
- **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).
|
||||||
|
|
||||||
## Monitoring and logs
|
## Monitoring and logs
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -36,7 +36,8 @@ Guides for operating RustProxy: installation, publishing services, security, cer
|
|||||||
|
|
||||||
## Performance and delivery
|
## Performance and delivery
|
||||||
|
|
||||||
- [Cache](CACHE.md) — HOT/COLD cache, RFC 9111 `Vary` matching/normalization, safe static-asset cookie exceptions, freshness, `Cache-Status` and invalidation.
|
- [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 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.
|
- [Response delivery](RESPONSE_DELIVERY.md) — compression, transformations and response headers.
|
||||||
|
|
||||||
## Operations
|
## Operations
|
||||||
|
|||||||
+167
@@ -0,0 +1,167 @@
|
|||||||
|
# VCL import: supported instructions and exact effects
|
||||||
|
|
||||||
|
This guide describes the VCL **subset implemented by RustProxy 0.38.10**, 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.
|
||||||
|
|
||||||
|
## Where to import, rule order and activation
|
||||||
|
|
||||||
|
- **Settings -> Cache -> Rules**: global cache rules, optionally targeted to particular vhosts.
|
||||||
|
- **Vhosts -> Cache -> Cache rules for this vhost**: rules for one vhost (ordinary or Docker-generated). **Ignore global cache rules** disables the global rules for that vhost.
|
||||||
|
- Imported rules and graphical rules use the same engine. Within each stage, **vhost rules run first**, followed by applicable global rules. A vhost edit to the same header or supported scalar setting wins over a conflicting global edit. In one scope, later matching edits win unless `stop`/`return(...)` terminates the stage.
|
||||||
|
- A terminal `return(hash)` ends normal `vcl_recv` processing but **does not skip `vcl_hash`**. A terminal `return(pass)` skips lookup and `vcl_hash`. A return/stop does not skip the other, independent response/deliver stages.
|
||||||
|
- Regular cache admission still requires enabled global/vhost caching, an eligible route, method, request policy and response. A `return(hash)` cannot turn on a disabled cache or override `Authorization`/access controls. Supported request header/cookie/query rewrites and backend header edits can still affect an ordinary reverse-proxy response even when cache storage is disabled; deliver-stage edits apply to the final response on HIT, MISS and BYPASS. These rules do not apply to embedded Web Server sources or RustProxy's administration/control-plane responses.
|
||||||
|
|
||||||
|
## Supported VCL statements
|
||||||
|
|
||||||
|
| 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(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` | `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. |
|
||||||
|
| `vcl_hash` | `hash_data(req.url);` / `hash_data(req.http.Host);` | Accepted as built-in operations with **no additional rule**: URL/query and normalized Host are already part of the RustProxy key. Other expressions are not imported. `hash_data` in `vcl_recv` is rejected with a warning. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `set beresp.ttl = 60s;` and `set beresp.grace = 30s;` | Configures cache freshness/grace, within RustProxy limits and policy. Units: `ms`, `s`, `m`, `h`, `d`, `w`, `y` (rounded to whole seconds). Does not automatically rewrite the browser's `Cache-Control`. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `set beresp.uncacheable = true;` / `= false;` | **RustProxy-specific difference:** `true` disables storing; `false` reverses an earlier **rule-imposed** no-store decision. Varnish itself ignores resetting `beresp.uncacheable` from true to false. In RustProxy, `false` does **not** ignore origin `private`, `no-store`, `Set-Cookie` or other cache admission restrictions. A vhost `false` overrides conflicting global `true`. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `set beresp.http.X-Name = "literal";` | Replaces the named origin header before cache admission and before delivery. Only a **single quoted constant string** is supported, on an allowed header. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `unset beresp.http.X-Name;` | Removes the named origin header before cache admission and delivery. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `unset beresp.http.Set-Cookie;` | A **special dedicated action**, which removes the origin's Set-Cookie before cache policy. Only safe for genuinely public responses. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `return(pass);`, `return(hit_for_pass);` or `return(uncacheable);` | Marks the response as not storable; **does not** create Varnish hit-for-pass markers. |
|
||||||
|
| `vcl_backend_response` / `vcl_fetch` | `return(deliver);` | Stops the remaining rules in that response hook. |
|
||||||
|
| `vcl_deliver` | `set resp.http.X-Name = "literal";` | Sets/replaces the named header **only on the outgoing response**. Does not change the cache's stored object or variant key. |
|
||||||
|
| `vcl_deliver` | `unset resp.http.X-Name;` | Removes the named header **only from the outgoing response**, including an HIT. |
|
||||||
|
| `vcl_deliver` | `return(deliver);` | Stops further deliver-stage rules on the matching path. |
|
||||||
|
|
||||||
|
For `set` and `unset` header instructions, HTTP header names are case-insensitive. Quoted strings accept `\"` and `\\` escapes; regex escapes such as `\s` and backreferences such as `\1` are kept literally. **Malformed statements with extra operands are warned about and skipped**, rather than silently treating their prefix as a valid action. Unterminated quoted strings and block comments reject the import. Valid headers and values are checked when a rule is compiled. The importer reports unsupported/invalid statements as warnings (skipped) or parsing errors (import rejected), rather than running them as Varnish code. A rejected header edit no longer discards adjacent valid statements, and long supported action blocks are split at the rule action limit. For repeated header fields, `set` replaces the **entire** field (not one value); `unset` removes **all occurrences** of that field. Assigning `""` creates an empty field, which is not the same as removing it. Neither action merges individual comma-separated `Vary` members. The panel also offers graphical-only actions such as **Set header if missing**, **Ignore backend Cache-Control**, cookie allowlists and explicit query-parameter filtering; do not assume those actions have a one-to-one VCL syntax.
|
||||||
|
|
||||||
|
### Request header changes: scope and safeguards
|
||||||
|
|
||||||
|
```vcl
|
||||||
|
sub vcl_recv {
|
||||||
|
if (req.url ~ "^/catalog") {
|
||||||
|
unset req.http.X-Tracking;
|
||||||
|
set req.http.X-Device = "mobile";
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub vcl_hash {
|
||||||
|
hash_data(req.http.X-Device);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
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_`.
|
||||||
|
|
||||||
|
## Recognized conditions and expressions
|
||||||
|
|
||||||
|
| Form | Example | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| URL, method, request headers | `req.url ~ "^/assets/"`, `req.method == "GET"`, `req.http.Cookie` | `req.url` includes path and query; an unqualified request header tests presence. `bereq.url` and `bereq.http.X` are accepted as rule-request aliases. |
|
||||||
|
| Backend/delivery status and headers | `beresp.status == 200`, `beresp.http.Content-Type ~ "^text/"`, `resp.http.X-Flag` | Evaluated against the response at the relevant stage; earlier supported header mutations are visible to subsequent conditions. |
|
||||||
|
| Comparisons | `==`, `!=`, `~`, `!~` | Equality and regex matching for supported request/response variables. |
|
||||||
|
| Status comparisons | `beresp.status >= 500`, `resp.status < 400` | Also accepts `>`, `<=`, `==`, `!=`. |
|
||||||
|
| Branching | `if`, `elsif`, `else`, nested blocks, `&&`, `||`, `!`, parentheses | Branch guards are preserved in the generated rules, subject to the rule/condition limits. |
|
||||||
|
|
||||||
|
`client.ip` with a Varnish ACL is **not imported**; the graphical rules have a client IP/CIDR condition instead. `include`, external modules, backend/ACL/probe definitions and custom subroutines are not loaded as executable configuration. Arbitrary functions, variables, string concatenation, dynamic header expressions, `pipe`, `restart`, `purge`, `synth` and hit-for-miss/hit-for-pass behavior are **not** implemented. Import is a conversion, not a promise of runtime Varnish equivalence.
|
||||||
|
|
||||||
|
Limits include a maximum VCL source of 256 KiB; the compiled cache-rule lists are limited to 128 rules, 16 conditions and 16 actions per rule. A complex boolean expression may expand to too many rules and be skipped with a warning. Use the graphical tester to verify the imported behavior.
|
||||||
|
|
||||||
|
## `Vary`: before or after the cache?
|
||||||
|
|
||||||
|
`Vary` is an **allowed** header for both backend (`beresp`) and deliver (`resp`) actions. The phase matters:
|
||||||
|
|
||||||
|
| VCL statement | Internal cache / stored variants | Response sent to clients and downstream proxies |
|
||||||
|
|---|---|---|
|
||||||
|
| `set beresp.http.Vary = "Accept-Language";` | Replaces the origin's complete `Vary` field before the variant plan is built. Distinct `Accept-Language` requests can have separate stored variants. | Sends the replaced `Vary`, unless later processing or deliver rules modify it. |
|
||||||
|
| `unset beresp.http.Vary;` | Drops origin-specified variant dimensions **before storage**. A response that actually depends on a removed dimension may be reused for the wrong client. | Removes the origin field unless safety handling re-adds `Vary: Cookie`/`Authorization` or later rules set it. |
|
||||||
|
| `set resp.http.Vary = "Accept-Language";` | **No change** to the variant dimensions already computed/stored. | Replaces the final `Vary`; may incorrectly describe the cache key to a CDN. |
|
||||||
|
| `unset resp.http.Vary;` | **No change** to internal variants or HIT behavior. | Removes `Vary` downstream. Dangerous when the response varies by language, encoding, cookies or credentials. |
|
||||||
|
|
||||||
|
Important details:
|
||||||
|
|
||||||
|
- `set beresp.http.Vary = "X-Device";` **replaces**, not appends: any previous `Vary: Accept-Encoding` or `Vary: Cookie` is discarded by that assignment. The importer does **not** support expressions such as `beresp.http.Vary + ", X-Device"` or `regsub(beresp.http.Vary, ...)` to merge values. List all required dimensions explicitly in a constant string, or configure them at the origin.
|
||||||
|
- `Vary: *` and malformed `Vary` prevent shared reuse. With a valid `Vary`, RustProxy uses **all retained** dimensions and normalizes selected header families as described in [Cache](CACHE.md#vary-matching-rfc-9111-41).
|
||||||
|
- **Safety exception:** when a request carrying `Cookie` is explicitly allowed by `return(hash)` (or forced caching), RustProxy makes its variant cookie-dependent and can **re-add `Vary: Cookie`** before storage/delivery even if `beresp.http.Vary` removed it. Forced credential variants can likewise add `Vary: Authorization`. This is not a general VCL override of protected request policies.
|
||||||
|
- **Static-file exception:** `Ignore Vary: Cookie for public static assets` may remove just the `Cookie` member from `Vary` only under the documented static extension, explicit `public`, freshness and privacy checks. It does not erase other dimensions. The static-cookie options are separate from manually setting/unsetting `Vary` in VCL.
|
||||||
|
- `vcl_deliver` runs **after** variant selection. Although `unset resp.http.Vary` is accepted, using it on a variant response can make a browser/CDN store an unsafe representation. Do not remove `Vary` only to increase the HIT ratio.
|
||||||
|
|
||||||
|
Example for a response that **really varies only by language**:
|
||||||
|
|
||||||
|
```vcl
|
||||||
|
sub vcl_backend_response {
|
||||||
|
if (bereq.url ~ "^/catalog") {
|
||||||
|
set beresp.http.Vary = "Accept-Language";
|
||||||
|
set beresp.http.Cache-Control = "public, max-age=60";
|
||||||
|
unset beresp.http.X-Powered-By;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
This does **not** claim that all catalog responses are safe to share: the application must not vary them by sessions, cookies, compression, permissions or other request headers unless those dimensions are also retained. If compression can change representation bytes, preserve the corresponding `Accept-Encoding` semantics.
|
||||||
|
|
||||||
|
## Removing headers, `Cache-Control` and `Set-Cookie`
|
||||||
|
|
||||||
|
| Example | When removed/changed | Does it affect cache admission? |
|
||||||
|
|---|---|---|
|
||||||
|
| `unset beresp.http.X-Debug;` | On origin response, before storage and client delivery | Only indirectly, e.g. via metadata/policy if applicable |
|
||||||
|
| `unset resp.http.X-Debug;` | On final response (HIT/MISS/BYPASS) | **No** |
|
||||||
|
| `unset beresp.http.Cache-Control;` | Removes origin cache policy before storage | **Yes:** can remove `no-cache`, `private` or `no-store` constraints |
|
||||||
|
| `set beresp.http.Cache-Control = "public, max-age=60";` | Replaces origin policy before storage | **Yes:** origin policy is evaluated as rewritten |
|
||||||
|
| `set resp.http.Cache-Control = "public, max-age=60";` | Changes the client-facing header only | **No:** cannot make a BYPASS into a stored HIT |
|
||||||
|
| `unset beresp.http.Set-Cookie;` | Removes Set-Cookie via special backend rule | **Yes:** removes a reason to reject shared storage |
|
||||||
|
|
||||||
|
**Security:** rewriting or removing `Cache-Control: private`/`no-store` in `vcl_backend_response`, or stripping `Set-Cookie`, **explicitly discards the origin's protection**. RustProxy's storage policy sees the rewritten response. Only do this for representations proven identical for all users; never for login, account or session-dependent pages. The graphical **Ignore backend Cache-Control** action can likewise override origin privacy directives for RustProxy cache admission even while preserving them in downstream headers; it must be treated as an explicit policy override. Merely enabling Varnish compatibility does *not* strip these directives. `set beresp.ttl` does not by itself erase `private` or `no-store`.
|
||||||
|
|
||||||
|
The following headers are **protected against general `set`/`unset` actions** in both `beresp.http.*` and `resp.http.*`: `Connection`, `Content-Length`, `Content-Encoding`, `Content-Range`, `Date`, `Keep-Alive`, `Proxy-Authenticate`, `Proxy-Authorization`, `Set-Cookie`, `TE`, `Trailer`, `Transfer-Encoding`, `Upgrade`, `Host`, `Alt-Svc`. An attempted edit is skipped with a warning. The one exception is the **dedicated** `unset beresp.http.Set-Cookie` removal action; arbitrary `set beresp.http.Set-Cookie` and `unset resp.http.Set-Cookie` are not supported. Other proxy subsystems may also generate or normalize response headers after backend rules have run.
|
||||||
|
|
||||||
|
Example for final-response-only cleanup (does not affect cache identity, TTL or origin storage):
|
||||||
|
|
||||||
|
```vcl
|
||||||
|
sub vcl_deliver {
|
||||||
|
unset resp.http.X-Debug;
|
||||||
|
set resp.http.X-Policy-Name = "catalog-public";
|
||||||
|
return(deliver);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
## Cookies and `return(hash)`
|
||||||
|
|
||||||
|
In compatibility mode (`cache.varnish_compatible=true`), `return(hash)` can opt in to caching eligible GET/HEAD requests with Cookie. **It does not remove the Cookie header.** Remaining cookie values partition the RustProxy variant, and the response includes a Cookie `Vary` dimension for downstream caches. This is safer than sharing all cookie-bearing requests, but reduces HIT rates. Explicit `return(pass)` should intercept session cookies **before** `return(hash)`:
|
||||||
|
|
||||||
|
```vcl
|
||||||
|
sub vcl_recv {
|
||||||
|
if (req.http.Cookie ~ "(^|; *)session=") {
|
||||||
|
return(pass);
|
||||||
|
}
|
||||||
|
if (req.url ~ "^/catalog") {
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
return(pass);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `unset req.http.Cookie;` only when the origin does not need **any** cookies for that route. 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.
|
||||||
|
|
||||||
|
## `no-cache` and TTL
|
||||||
|
|
||||||
|
- `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.38.10.** 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. Import VCL in the appropriate global or per-vhost Rules editor. With warnings the importer **does not add the converted rules automatically**. Read each warning; either revise the VCL and rerun or explicitly click **Add partial import (reviewed)**. No VCL is executed directly at runtime. The resulting rules are still unsaved until you save the settings. Closing the importer or modifying its source invalidates any outstanding parse result; an older API response cannot add rules after cancellation. Do not treat **Copy as VCL** as a backup/round trip; use RustProxy configuration exports for exact rules.
|
||||||
|
2. Expand **Test a request** (two compact sections: HTTP request and backend response) in the global, ordinary-vhost or Docker-vhost Rules editor. Supply URL or path, method, Cookie/other request headers, client IP, example backend status and headers (`Cache-Control`, `Vary`, `Set-Cookie`); inspect matched/suppressed rules, backend header edits, cacheability, TTL/grace and deliver actions. The global tester previews unsaved global rules with the selected vhost's saved rules; a local tester previews unsaved vhost rules with saved applicable global rules, unless **Ignore global cache rules** is enabled. For a path-only test the current local hostname is sent as `Host` if no explicit Host header was provided; full URLs and explicit Host headers win. The tester does **not** simulate other unsaved cache settings and does **not** send a request to the backend. A not-yet-saved vhost may lack its saved settings in the preview. Use real HTTP requests for final HIT/MISS verification.
|
||||||
|
3. Save the rules, then send the same `GET` twice (and change one `Vary` dimension) against a real reverse-proxy vhost. Inspect `X-Cache` / `X-Cache-Reason` or `Server-Timing`, depending on enabled diagnostics, plus the **actual delivered headers**. A response can be a MISS yet remain ineligible for storage.
|
||||||
|
4. Test session cookies, `Authorization`, privacy directives, compressed variants, HIT versus BYPASS and global versus per-vhost conflicts before production. If the origin's behavior differs by a header, verify the correct `Vary` is present in both the internal storage decision and the downstream response.
|
||||||
|
|
||||||
|
Optional front-end smoke tests (with Python Playwright and Chromium installed): `python3 tests/browser/cache_rules_import_smoke.py` and `python3 tests/browser/cache_rules_tester_smoke.py` from the project root. It exercises the **standalone browser editor** with mocked API responses, including global/per-vhost import and cancellation races; it does **not** replace real Rust integration tests for cache correctness.
|
||||||
|
|
||||||
|
See [HTTP cache](CACHE.md), [Cache API](API.md), and [Security](SECURITY.md) for cache settings and operational limits.
|
||||||
@@ -13,6 +13,12 @@ A **Vhost** publishes one or more hostnames on named HTTP/HTTPS listeners. Its s
|
|||||||
|
|
||||||
A Vhost may bind several frontends. Hostnames and selected listeners must match: the existence of a certificate or an upstream does not create DNS entries or a listening socket. Existing Vhosts retain their bindings when new listeners are created.
|
A Vhost may bind several frontends. Hostnames and selected listeners must match: the existence of a certificate or an upstream does not create DNS entries or a listening socket. Existing Vhosts retain their bindings when new listeners are created.
|
||||||
|
|
||||||
|
## Cache rules: tester and VCL guide
|
||||||
|
|
||||||
|
In **Vhosts → Edit → Cache**, use the same compact **Test a request** form as in global Cache settings and Docker vhosts. The request and example backend response have separate groups. Tests preview the **unsaved local rules** with the **saved global rules** for that vhost (or exclude them if **Ignore global cache rules** is checked). For a path-only URL the current hostname field is used as the `Host` header, unless you specify `Host` explicitly. This simulates rule decisions without contacting the backend and does not model other unsaved cache settings.
|
||||||
|
|
||||||
|
Use **Cache & VCL guide** next to the local rule editor to open the shared instructional modal; **Insert into VCL importer** targets **this vhost**, not global rules. Review import warnings, verify rule priority and save the vhost to activate changes. See [Cache rules](CACHE.md#cache-rules-vcl-style) and [VCL reference](VCL.md).
|
||||||
|
|
||||||
## Live request-rate graph
|
## Live request-rate graph
|
||||||
|
|
||||||
Each Vhost card has a **Lifetime request rate** chart showing sampled requests per second since the current browser session began observing that Vhost. The Y-axis automatically follows recent traffic (85th percentile of up to 24 newest displayed samples, with 25% headroom). One anomalous surge no longer compresses normal traffic into a flat line. After sustained changes in request load, the range adjusts up or down automatically.
|
Each Vhost card has a **Lifetime request rate** chart showing sampled requests per second since the current browser session began observing that Vhost. The Y-axis automatically follows recent traffic (85th percentile of up to 24 newest displayed samples, with 25% headroom). One anomalous surge no longer compresses normal traffic into a flat line. After sustained changes in request load, the range adjusts up or down automatically.
|
||||||
|
|||||||
+72
-5
@@ -335,14 +335,14 @@
|
|||||||
"cacheVarnishCompatibleHelp": "A browser hard reload (Shift+F5, Cache-Control: no-cache or max-age=0, Pragma: no-cache) keeps a fresh cache HIT, including Age and the hit count.",
|
"cacheVarnishCompatibleHelp": "A browser hard reload (Shift+F5, Cache-Control: no-cache or max-age=0, Pragma: no-cache) keeps a fresh cache HIT, including Age and the hit count.",
|
||||||
"cacheVarnishCompatibleInfoLabel": "Varnish-compatible cache behavior",
|
"cacheVarnishCompatibleInfoLabel": "Varnish-compatible cache behavior",
|
||||||
"cacheVarnishCompatibleSafeguards": "Still honors client no-store, only-if-cached (504 on MISS, no origin access or background refresh), min-fresh and max-stale (including max-stale=0 during grace). Cookie exceptions for static files, Authorization, Vary, PURGE/BAN, HOT/COLD and transforms work as before.",
|
"cacheVarnishCompatibleSafeguards": "Still honors client no-store, only-if-cached (504 on MISS, no origin access or background refresh), min-fresh and max-stale (including max-stale=0 during grace). Cookie exceptions for static files, Authorization, Vary, PURGE/BAN, HOT/COLD and transforms work as before.",
|
||||||
"cacheVarnishCompatibleBackendHelp": "Origin no-cache with ETag/Last-Modified remains revalidatable. Setting a positive fallback TTL explicitly permits public no-cache responses to be reused for that TTL, even without validators. Origin private/no-store/Set-Cookie and Surrogate-Control: no-store are never overridden. Zero-TTL entries may still provide stale-if-error or validator revalidation.",
|
"cacheVarnishCompatibleBackendHelp": "Origin no-cache with ETag/Last-Modified remains revalidatable. In compatibility mode a positive fallback TTL can explicitly cache eligible no-cache responses without public or a validator. Private/no-store/Set-Cookie and Surrogate-Control: no-store remain blocked. This is not vanilla Varnish behavior.",
|
||||||
"cacheVarnishCompatibleModeHelp": "Grace defaults to 60 seconds and can be changed in the field below. It only applies to eligible fresh-at-storage objects without an origin stale-while-revalidate directive; explicit =0 is honored. Off restores strict client reload semantics. Switching modes invalidates existing cached entries. This is a compatibility subset, not full Varnish VCL.",
|
"cacheVarnishCompatibleModeHelp": "Grace defaults to 60 seconds and can be changed in the field below. It only applies to eligible fresh-at-storage objects without an origin stale-while-revalidate directive; explicit =0 is honored. Off restores strict client reload semantics. Switching modes invalidates existing cached entries. This is a compatibility subset, not full Varnish VCL.",
|
||||||
"cacheSafety": "Complete public-safe GET responses are cached. Authorization, cookies and private/no-store responses still bypass. One byte range can be served from a complete cached object; multipart/unsupported ranges pass through.",
|
"cacheSafety": "Only eligible GET/HEAD responses. Authorization and private/no-store normally bypass storage. Cookies bypass unless eligible VCL return(hash) opts in under compatibility mode. Unsupported range requests bypass.",
|
||||||
"cacheMemory": "HOT allocated budget (MiB)",
|
"cacheMemory": "HOT allocated budget (MiB)",
|
||||||
"cacheObject": "Maximum object (KiB)",
|
"cacheObject": "Maximum object (KiB)",
|
||||||
"cacheEntries": "Maximum entries",
|
"cacheEntries": "Maximum entries",
|
||||||
"cacheMaxTtl": "Maximum TTL (seconds)",
|
"cacheMaxTtl": "Maximum TTL (seconds)",
|
||||||
"cacheDefaultTtl": "Fallback TTL for public responses (0 = off)",
|
"cacheDefaultTtl": "Fallback TTL (seconds): public; headerless/no-cache in compatibility mode (0 = off)",
|
||||||
"bypassQuery": "Bypass URLs with a query string",
|
"bypassQuery": "Bypass URLs with a query string",
|
||||||
"cachePrefixes": "Bypass path prefixes, one per line",
|
"cachePrefixes": "Bypass path prefixes, one per line",
|
||||||
"cacheAgeHelp": "Age is sent on cache hits unless an explicit response-header rule removes or replaces it. Such Age rules are wire-only and do not change cache freshness. Counters remain available even when diagnostic headers are hidden. Only cache-affecting configuration changes invalidate incompatible objects; managed software updates hand hot objects to cold storage when the cold tier is enabled.",
|
"cacheAgeHelp": "Age is sent on cache hits unless an explicit response-header rule removes or replaces it. Such Age rules are wire-only and do not change cache freshness. Counters remain available even when diagnostic headers are hidden. Only cache-affecting configuration changes invalidate incompatible objects; managed software updates hand hot objects to cold storage when the cold tier is enabled.",
|
||||||
@@ -3369,6 +3369,47 @@
|
|||||||
"globalPolicySummary": "Rule status",
|
"globalPolicySummary": "Rule status",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"cacheTabRules": "Rules",
|
"cacheTabRules": "Rules",
|
||||||
|
"cacheVarnishCompatibleVclHelp": "Use return(pass) for session cookies before return(hash) for selected public routes. In Rules, the Cache & VCL guide explains Vary, header edits and importer limits. Per-vhost overrides take precedence.",
|
||||||
|
"cacheGuideInsert": "Insert into VCL importer",
|
||||||
|
"cacheGuideImporterUnavailable": "Open Cache → Rules after the configuration has loaded and try again.",
|
||||||
|
"cacheGuideOpen": "Cache & VCL guide",
|
||||||
|
"cacheGuideEyebrow": "CACHE SETTINGS · VCL SUBSET",
|
||||||
|
"cacheGuideTitle": "Practical cache & VCL guide",
|
||||||
|
"cacheGuideIntro": "Practical notes for RustProxy, not a promise of complete Varnish VCL compatibility. Only imported and accepted rules are executed.",
|
||||||
|
"cacheGuideModeOn": "Varnish-compatible: ON",
|
||||||
|
"cacheGuideModeOff": "Varnish-compatible: OFF (RFC)",
|
||||||
|
"cacheGuideTtlStatus": "Fallback TTL: {seconds} s",
|
||||||
|
"cacheGuideGraceStatus": "Grace: {seconds} s",
|
||||||
|
"cacheGuideUnsaved": "Values reflect the current form, which may contain unsaved changes.",
|
||||||
|
"cacheGuideCacheOffNote": "Cache is disabled in this form. VCL rules cannot enable storage while the cache or route is disabled.",
|
||||||
|
"cacheGuideRfcNote": "Strict RFC mode: origin no-cache requires validation before reuse, even with a fallback TTL.",
|
||||||
|
"cacheGuideCompatNote": "Compatibility mode: eligible origin no-cache may use the positive fallback TTL without requiring public. Private/no-store/Set-Cookie still block storage.",
|
||||||
|
"cacheGuideCompatZeroNote": "Compatibility mode with fallback TTL = 0: no-cache needs ETag/Last-Modified for revalidation; it cannot become a fresh HIT without a TTL.",
|
||||||
|
"cacheGuideFreshnessTitle": "no-cache, TTL and grace",
|
||||||
|
"cacheGuideFreshnessText": "With Varnish compatibility and a positive fallback TTL, an eligible Cache-Control: no-cache response can be served as HIT for that TTL without public. With compatibility off, no-cache requires validation before reuse. Grace is a separate stale-response window, not a fallback TTL.",
|
||||||
|
"cacheGuideFreshnessWarning": "Do not expect a HIT for private/no-store/Set-Cookie or when the request is BYPASS. This override is not the default Varnish VCL behavior.",
|
||||||
|
"cacheGuideCookieTitle": "Cookie and return(hash)",
|
||||||
|
"cacheGuideCookieText": "Cookies normally trigger BYPASS. In compatible mode, an explicit return(hash) can admit eligible Cookie requests; the full Cookie remains on the backend request and partitions the cache. Catch session cookies with return(pass) first.",
|
||||||
|
"cacheGuideCookieWarning": "unset req.http.Cookie removes ALL cookies, including from the request sent to the backend. Authorization and authentication protections still apply.",
|
||||||
|
"cacheGuideVaryTitle": "Vary and cache variants",
|
||||||
|
"cacheGuideVaryText": "set/unset beresp.http.Vary changes variant selection before storing. set/unset resp.http.Vary only changes what the client sees; it does not repair the stored cache key. An assignment replaces the whole Vary list.",
|
||||||
|
"cacheGuideVaryWarning": "Never remove a required Vary dimension for a personalized or encoded response. RustProxy may restore Vary: Cookie for cookie-partitioned objects; static Ignore Vary: Cookie requires public and other safety checks.",
|
||||||
|
"cacheGuideHeadersTitle": "set/unset headers",
|
||||||
|
"cacheGuideHeadersText": "beresp.http.* edits the backend response before the cache decision; resp.http.* edits only the delivered response. Removing beresp.http.Cache-Control can change cache eligibility, while removing resp.http.Cache-Control cannot.",
|
||||||
|
"cacheGuideHeadersWarning": "Only literal string assignments are imported; protected transport/body headers cannot be edited. Removing Set-Cookie requires a dedicated backend action and is unsafe for session responses.",
|
||||||
|
"cacheGuideRequestTitle": "Request headers and storage overrides",
|
||||||
|
"cacheGuideRequestText": "Safe set/unset req.http headers are applied before subsequent rules, hashing and forwarding to the origin. beresp.uncacheable = false reverses an earlier rule's no-store decision, but does not override origin private/no-store/Set-Cookie.",
|
||||||
|
"cacheGuideRequestWarning": "Authorization, Cookie (except dedicated unset), Cache-Control and forwarding/transport headers are protected in request rules. Complex URL rewrites are warned about, not guessed. Always review import warnings.",
|
||||||
|
"cacheGuideStagesTitle": "VCL stages and rule precedence",
|
||||||
|
"cacheGuideStagesText": "vcl_recv handles pass/hash, safe set/unset req.http headers and request rewrites; vcl_hash supports selected hash_data(req.http.X); vcl_backend_response handles TTL, grace, beresp.uncacheable true/false and backend headers; vcl_deliver edits final headers, even on HIT or BYPASS.",
|
||||||
|
"cacheGuidePrecedenceText": "Rules for the vhost are evaluated before matching global rules. Per-vhost changes win on conflicting supported settings and headers, or global rules may be disabled for the vhost. Importing VCL converts it into graphical rules; review warnings and the resulting order before saving.",
|
||||||
|
"cacheGuideUnsupportedText": "Not yet a full Varnish interpreter: vcl_hit/vcl_miss/vcl_pass hooks, arbitrary sub/call, VMOD, ACL expressions, beresp.keep, hit-for-miss/pass, restart, retry, synth and purge are not executed as VCL.",
|
||||||
|
"cacheGuideDiagnoseTitle": "Why isn't it a HIT?",
|
||||||
|
"cacheGuideDiagnoseText": "Enable X-Cache and detailed reason headers; disable Only on HIT while debugging. Send two identical GET requests with curl (not a browser hard reload), then compare the cache outcome and origin headers.",
|
||||||
|
"cacheGuideDiagnoseReasons": "BYPASS usually means request exclusion (Cookie, Authorization, route or query). MISS means the backend was contacted, but does not prove that the response was stored. Check X-Cache-Reason, Cache-Control, Set-Cookie, Vary and Age.",
|
||||||
|
"cacheGuideScope": "These VCL rules affect reverse-proxy vhosts; they do not execute on the embedded administration panel or all Web Server sources. Test on a non-production vhost first.",
|
||||||
|
"cacheGuideDocsVcl": "Complete supported VCL syntax and limits",
|
||||||
|
"cacheGuideDocsCache": "HTTP cache policy and diagnostics",
|
||||||
"cacheRulesHelp": "Conditional rules in the spirit of Varnish VCL: decide what is cached, how the cache key is built, how long objects live and which headers clients get. Request rules run before the cache lookup, response rules on a backend response, deliver rules on every response. Vhost rules (vhost editor → Cache) run before these global rules. Saved with Save cache settings.",
|
"cacheRulesHelp": "Conditional rules in the spirit of Varnish VCL: decide what is cached, how the cache key is built, how long objects live and which headers clients get. Request rules run before the cache lookup, response rules on a backend response, deliver rules on every response. Vhost rules (vhost editor → Cache) run before these global rules. Saved with Save cache settings.",
|
||||||
"vhCacheRulesTitle": "Cache rules for this vhost",
|
"vhCacheRulesTitle": "Cache rules for this vhost",
|
||||||
"vhCacheRulesHelp": "Run before the global rules from Settings → Cache → Rules. When both set the same thing (TTL, grace, pass, no store) the vhost rule wins.",
|
"vhCacheRulesHelp": "Run before the global rules from Settings → Cache → Rules. When both set the same thing (TTL, grace, pass, no store) the vhost rule wins.",
|
||||||
@@ -3382,7 +3423,7 @@
|
|||||||
"cacheRulesImportHelp": "Paste VCL (vcl_recv, vcl_hash, vcl_backend_response, vcl_deliver). Supported statements become rules; everything else is listed as a warning. Imported rules are added below and saved with the form.",
|
"cacheRulesImportHelp": "Paste VCL (vcl_recv, vcl_hash, vcl_backend_response, vcl_deliver). Supported statements become rules; everything else is listed as a warning. Imported rules are added below and saved with the form.",
|
||||||
"cacheRulesImportRun": "Convert to rules",
|
"cacheRulesImportRun": "Convert to rules",
|
||||||
"cacheRulesImportDone": "Imported {count} rules. Review them and save.",
|
"cacheRulesImportDone": "Imported {count} rules. Review them and save.",
|
||||||
"cacheRulesImportWarnings": "Not imported:",
|
"cacheRulesImportWarnings": "Import warnings: some statements were skipped or approximated:",
|
||||||
"cacheRulesVclPreview": "VCL preview (read-only)",
|
"cacheRulesVclPreview": "VCL preview (read-only)",
|
||||||
"cacheRulesGlobalApply": "{count} global rules also apply to this vhost: {names}.",
|
"cacheRulesGlobalApply": "{count} global rules also apply to this vhost: {names}.",
|
||||||
"cacheRulesGlobalSkipped": "{count} global rules are ignored for this vhost.",
|
"cacheRulesGlobalSkipped": "{count} global rules are ignored for this vhost.",
|
||||||
@@ -3411,6 +3452,7 @@
|
|||||||
"cacheRulesResultNotStored": "Not stored ({reason})",
|
"cacheRulesResultNotStored": "Not stored ({reason})",
|
||||||
"cacheRulesResultPass": "Bypass ({reason})",
|
"cacheRulesResultPass": "Bypass ({reason})",
|
||||||
"cacheRulesResultRequest": "Request rules",
|
"cacheRulesResultRequest": "Request rules",
|
||||||
|
"cacheRulesResultRequestHeaders": "Request header edits",
|
||||||
"cacheRulesResultResponse": "Response rules",
|
"cacheRulesResultResponse": "Response rules",
|
||||||
"cacheRulesResultDeliver": "Deliver headers",
|
"cacheRulesResultDeliver": "Deliver headers",
|
||||||
"cacheRulesResultKey": "Cache key",
|
"cacheRulesResultKey": "Cache key",
|
||||||
@@ -3478,19 +3520,27 @@
|
|||||||
"cacheRuleOpCidr": "is in",
|
"cacheRuleOpCidr": "is in",
|
||||||
"cacheRuleAction": "Action",
|
"cacheRuleAction": "Action",
|
||||||
"cacheRuleActionPass": "Bypass cache (pass)",
|
"cacheRuleActionPass": "Bypass cache (pass)",
|
||||||
|
"cacheRuleActionLookup": "Allow Cookie cache lookup (hash)",
|
||||||
"cacheRuleActionStripCookies": "Remove cookies",
|
"cacheRuleActionStripCookies": "Remove cookies",
|
||||||
"cacheRuleActionStripQuery": "Remove query parameters",
|
"cacheRuleActionStripQuery": "Remove query parameters",
|
||||||
|
"cacheRuleActionSetRequestHeader": "Set request header",
|
||||||
|
"cacheRuleActionRemoveRequestHeader": "Remove request header",
|
||||||
"cacheRuleActionHashHeader": "Add header to cache key",
|
"cacheRuleActionHashHeader": "Add header to cache key",
|
||||||
"cacheRuleActionHashCookie": "Add cookie to cache key",
|
"cacheRuleActionHashCookie": "Add cookie to cache key",
|
||||||
"cacheRuleActionTtl": "Set TTL",
|
"cacheRuleActionTtl": "Set TTL",
|
||||||
"cacheRuleActionGrace": "Set grace",
|
"cacheRuleActionGrace": "Set grace",
|
||||||
"cacheRuleActionNoStore": "Do not store",
|
"cacheRuleActionNoStore": "Do not store",
|
||||||
|
"cacheRuleActionAllowStore": "Allow storage (respect origin)",
|
||||||
"cacheRuleActionIgnoreCacheControl": "Ignore backend Cache-Control",
|
"cacheRuleActionIgnoreCacheControl": "Ignore backend Cache-Control",
|
||||||
"cacheRuleActionStripSetCookie": "Remove Set-Cookie",
|
"cacheRuleActionStripSetCookie": "Remove Set-Cookie",
|
||||||
|
"cacheRuleActionSetBackendHeader": "Set backend response header",
|
||||||
|
"cacheRuleActionRemoveBackendHeader": "Remove backend response header",
|
||||||
"cacheRuleActionSetHeader": "Set response header",
|
"cacheRuleActionSetHeader": "Set response header",
|
||||||
"cacheRuleActionRemoveHeader": "Remove response header",
|
"cacheRuleActionRemoveHeader": "Remove response header",
|
||||||
"cacheRuleActionHelpPass": "The request goes straight to the backend; nothing is read from or written to the cache.",
|
"cacheRuleActionHelpPass": "The request goes straight to the backend; nothing is read from or written to the cache.",
|
||||||
|
"cacheRuleActionHelpLookup": "Allow Cookie requests to use the cache in Varnish-compatible mode (return(hash)); session cookies should match an earlier pass rule. Remaining cookies are part of the cache variant.",
|
||||||
"cacheRuleActionHelpNoStore": "The response is delivered but not cached.",
|
"cacheRuleActionHelpNoStore": "The response is delivered but not cached.",
|
||||||
|
"cacheRuleActionHelpAllowStore": "Clears an earlier VCL Do not store decision. Does not ignore origin private/no-store, Set-Cookie, disabled routes or other safety checks.",
|
||||||
"cacheRuleActionHelpIgnoreCacheControl": "Caches even with no-cache, private or no-store from the backend (uses the TTL action or the default TTL). Responses with Set-Cookie still need Remove Set-Cookie.",
|
"cacheRuleActionHelpIgnoreCacheControl": "Caches even with no-cache, private or no-store from the backend (uses the TTL action or the default TTL). Responses with Set-Cookie still need Remove Set-Cookie.",
|
||||||
"cacheRuleActionHelpStripSetCookie": "Removes Set-Cookie from the backend response (stored and delivered), like unset beresp.http.Set-Cookie.",
|
"cacheRuleActionHelpStripSetCookie": "Removes Set-Cookie from the backend response (stored and delivered), like unset beresp.http.Set-Cookie.",
|
||||||
"cacheRuleKeepCookies": "keep cookies (empty = remove all)",
|
"cacheRuleKeepCookies": "keep cookies (empty = remove all)",
|
||||||
@@ -3701,6 +3751,23 @@
|
|||||||
"alertSettingsCertificateOrder": "The error threshold must be fewer days than the warning threshold.",
|
"alertSettingsCertificateOrder": "The error threshold must be fewer days than the warning threshold.",
|
||||||
"alertSettingsPercentOrder": "The error threshold must be higher than the warning threshold.",
|
"alertSettingsPercentOrder": "The error threshold must be higher than the warning threshold.",
|
||||||
"vhCacheStaticVaryCookie": "Ignore Vary: Cookie for public static assets (inherit/on/off)",
|
"vhCacheStaticVaryCookie": "Ignore Vary: Cookie for public static assets (inherit/on/off)",
|
||||||
"cacheStaticVaryCookie": "Ignore Vary: Cookie for public static assets"
|
"cacheStaticVaryCookie": "Ignore Vary: Cookie for public static assets",
|
||||||
|
"cacheRulesImportPending": "{count} converted rule(s) are waiting for approval. Review all warnings before adding them; no settings have been saved.",
|
||||||
|
"cacheRulesImportApplyPartial": "Add partial import (reviewed)",
|
||||||
|
"cacheRulesImportNoActions": "No executable cache rules were imported. The source may contain only built-in key operations or unsupported statements.",
|
||||||
|
"cacheGuideUncacheableDifference": "RustProxy's beresp.uncacheable = false only reverses an earlier cache-rule restriction; this differs from Varnish. Origin private/no-store and Set-Cookie still prevent storage unless separately and deliberately rewritten by a trusted rule.",
|
||||||
|
"cacheGuideBuiltInHash": "hash_data(req.url) and hash_data(req.http.Host) are already included in the internal cache key. vcl_hash can add one extra req.http.* header, but does not automatically generate the matching Vary response header.",
|
||||||
|
"cacheGuideStatusRestriction": "RustProxy currently stores only HTTP 200 responses. A TTL rule for 404/301 does not enable caching of those statuses; the former 404 template was removed to avoid suggesting otherwise.",
|
||||||
|
"cacheGuideVclPreviewWarning": "VCL export is a readable preview, not a lossless round-trip. If import reports warnings, rules are not added until you explicitly accept the partial result. Editing the source or closing the importer discards any pending import.",
|
||||||
|
"cacheRulesTesterRequestTitle": "HTTP request",
|
||||||
|
"cacheRulesTesterResponseTitle": "Backend response",
|
||||||
|
"cacheRulesTesterHelpGlobal": "Preview: unsaved global rules plus saved rules of the selected vhost. No backend traffic or counter updates.",
|
||||||
|
"cacheRulesTesterHelpVhost": "Preview: unsaved rules for this vhost plus saved global rules unless disabled. Other unsaved cache options are not simulated.",
|
||||||
|
"cacheGuideContextGlobal": "Global rules",
|
||||||
|
"cacheGuideContextVhost": "Vhost",
|
||||||
|
"cacheGuideContextDocker": "Docker vhost",
|
||||||
|
"cacheGuideScopeGlobal": "VCL examples are inserted into the global importer. The tester can also include saved rules of a selected vhost.",
|
||||||
|
"cacheGuideScopeVhost": "VCL examples are inserted only into this vhost importer. Vhost rules take priority over saved global rules, which can also be disabled. The TTL above is the global setting.",
|
||||||
|
"cacheGuideScopeDocker": "VCL examples are inserted only into this Docker vhost importer. Global rules behave the same as for ordinary vhosts unless disabled. The TTL above is the global setting."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+72
-5
@@ -335,14 +335,14 @@
|
|||||||
"cacheVarnishCompatibleHelp": "Twarde odświeżenie przeglądarki (Shift+F5, Cache-Control: no-cache lub max-age=0, Pragma: no-cache) nie wymusza odświeżenia świeżego wpisu HIT; Age i licznik trafień pozostają zachowane.",
|
"cacheVarnishCompatibleHelp": "Twarde odświeżenie przeglądarki (Shift+F5, Cache-Control: no-cache lub max-age=0, Pragma: no-cache) nie wymusza odświeżenia świeżego wpisu HIT; Age i licznik trafień pozostają zachowane.",
|
||||||
"cacheVarnishCompatibleInfoLabel": "Zachowanie cache w trybie zgodnym z Varnish",
|
"cacheVarnishCompatibleInfoLabel": "Zachowanie cache w trybie zgodnym z Varnish",
|
||||||
"cacheVarnishCompatibleSafeguards": "Nadal działają: no-store klienta, only-if-cached (504 przy MISS; bez żądania do backendu, także w tle), min-fresh i max-stale (także max-stale=0 przy grace). Zachowane są wyjątki cookies dla statycznych plików, Authorization, Vary, PURGE/BAN, HOT/COLD i transformacje.",
|
"cacheVarnishCompatibleSafeguards": "Nadal działają: no-store klienta, only-if-cached (504 przy MISS; bez żądania do backendu, także w tle), min-fresh i max-stale (także max-stale=0 przy grace). Zachowane są wyjątki cookies dla statycznych plików, Authorization, Vary, PURGE/BAN, HOT/COLD i transformacje.",
|
||||||
"cacheVarnishCompatibleBackendHelp": "Odpowiedzi no-cache backendu z ETag/Last-Modified nadal mogą być rewalidowane. Dodatni zapasowy TTL świadomie pozwala cache’ować publiczne odpowiedzi no-cache przez wskazany czas, także bez walidatora. Nie nadpisuje private/no-store/Set-Cookie ani Surrogate-Control: no-store. Wpisy z TTL=0 mogą nadal obsługiwać stale-if-error i rewalidację.",
|
"cacheVarnishCompatibleBackendHelp": "Odpowiedzi no-cache z ETag/Last-Modified nadal mogą być rewalidowane. W trybie zgodności dodatni zapasowy TTL może jawnie dopuścić no-cache do cache bez public i bez walidatora. Private/no-store/Set-Cookie oraz Surrogate-Control: no-store nadal blokują zapis. Nie jest to domyślne zachowanie Varnisha.",
|
||||||
"cacheVarnishCompatibleModeHelp": "Grace wynosi domyślnie 60 s i można go ustawić w polu poniżej. Dotyczy tylko kwalifikujących się wpisów zapisanych jako świeże, bez dyrektywy stale-while-revalidate; jawne =0 jest respektowane. Wyłączenie przywraca ścisłe odświeżanie przez klienta. Zmiana trybu unieważnia obecne wpisy. Nie jest to pełna emulacja VCL Varnish.",
|
"cacheVarnishCompatibleModeHelp": "Grace wynosi domyślnie 60 s i można go ustawić w polu poniżej. Dotyczy tylko kwalifikujących się wpisów zapisanych jako świeże, bez dyrektywy stale-while-revalidate; jawne =0 jest respektowane. Wyłączenie przywraca ścisłe odświeżanie przez klienta. Zmiana trybu unieważnia obecne wpisy. Nie jest to pełna emulacja VCL Varnish.",
|
||||||
"cacheSafety": "Cache zapisuje kompletne, bezpieczne odpowiedzi GET. Authorization, cookies oraz odpowiedzi private/no-store nadal omijają cache. Pojedynczy zakres bajtów może być obsłużony z pełnego obiektu cache; multipart i nieobsługiwane zakresy przechodzą do originu.",
|
"cacheSafety": "Cache obejmuje tylko dozwolone GET/HEAD. Authorization i private/no-store normalnie blokują zapis. Cookie powoduje BYPASS, chyba że jawna reguła VCL return(hash) dopuści je w trybie zgodności. Nieobsługiwane żądania zakresowe pomijają cache.",
|
||||||
"cacheMemory": "Limit alokowanej pamięci HOT (MiB)",
|
"cacheMemory": "Limit alokowanej pamięci HOT (MiB)",
|
||||||
"cacheObject": "Limit obiektu (KiB)",
|
"cacheObject": "Limit obiektu (KiB)",
|
||||||
"cacheEntries": "Maksymalna liczba wpisów",
|
"cacheEntries": "Maksymalna liczba wpisów",
|
||||||
"cacheMaxTtl": "Maksymalny TTL (sekundy)",
|
"cacheMaxTtl": "Maksymalny TTL (sekundy)",
|
||||||
"cacheDefaultTtl": "Zapasowy TTL odpowiedzi publicznych (0 = wył.)",
|
"cacheDefaultTtl": "Zapasowy TTL (s): public; brak nagłówków/no-cache w trybie Varnish (0 = wył.)",
|
||||||
"bypassQuery": "Pomijaj adresy z parametrami query",
|
"bypassQuery": "Pomijaj adresy z parametrami query",
|
||||||
"cachePrefixes": "Pomijane prefiksy ścieżek, po jednym w wierszu",
|
"cachePrefixes": "Pomijane prefiksy ścieżek, po jednym w wierszu",
|
||||||
"cacheAgeHelp": "Trafienia zawierają Age, chyba że jawna reguła nagłówka odpowiedzi go usunie lub zastąpi. Takie reguły Age działają tylko na odpowiedzi wysyłanej do klienta i nie zmieniają świeżości cache. Liczniki działają również przy ukrytych nagłówkach diagnostycznych. Tylko zmiany wpływające na cache unieważniają niezgodne obiekty; podczas zarządzanej aktualizacji hot cache jest przenoszony do cold storage, jeśli cold tier jest włączony.",
|
"cacheAgeHelp": "Trafienia zawierają Age, chyba że jawna reguła nagłówka odpowiedzi go usunie lub zastąpi. Takie reguły Age działają tylko na odpowiedzi wysyłanej do klienta i nie zmieniają świeżości cache. Liczniki działają również przy ukrytych nagłówkach diagnostycznych. Tylko zmiany wpływające na cache unieważniają niezgodne obiekty; podczas zarządzanej aktualizacji hot cache jest przenoszony do cold storage, jeśli cold tier jest włączony.",
|
||||||
@@ -3369,6 +3369,47 @@
|
|||||||
"globalPolicySummary": "Stan reguł",
|
"globalPolicySummary": "Stan reguł",
|
||||||
"cancel": "Anuluj",
|
"cancel": "Anuluj",
|
||||||
"cacheTabRules": "Reguły",
|
"cacheTabRules": "Reguły",
|
||||||
|
"cacheVarnishCompatibleVclHelp": "Użyj return(pass) dla cookies sesyjnych przed return(hash) na wybranych trasach publicznych. Poradnik Cache i VCL w Regułach opisuje Vary, zmiany nagłówków i ograniczenia importera. Nadpisania per-vhost mają pierwszeństwo.",
|
||||||
|
"cacheGuideInsert": "Wstaw do importera VCL",
|
||||||
|
"cacheGuideImporterUnavailable": "Otwórz Cache → Reguły po załadowaniu konfiguracji i spróbuj ponownie.",
|
||||||
|
"cacheGuideOpen": "Poradnik cache i VCL",
|
||||||
|
"cacheGuideEyebrow": "USTAWIENIA CACHE · PODZBIÓR VCL",
|
||||||
|
"cacheGuideTitle": "Cache i VCL – praktyczne wskazówki",
|
||||||
|
"cacheGuideIntro": "Wskazówki dotyczą RustProxy, a nie pełnej zgodności z Varnish VCL. Wykonywane są tylko reguły poprawnie przetworzone przez importer.",
|
||||||
|
"cacheGuideModeOn": "Kompatybilność Varnish: WŁ.",
|
||||||
|
"cacheGuideModeOff": "Kompatybilność Varnish: WYŁ. (RFC)",
|
||||||
|
"cacheGuideTtlStatus": "Zapasowy TTL: {seconds} s",
|
||||||
|
"cacheGuideGraceStatus": "Grace: {seconds} s",
|
||||||
|
"cacheGuideUnsaved": "Stan odczytano z bieżącego formularza. Niezapisane zmiany nie działają jeszcze na ruch.",
|
||||||
|
"cacheGuideCacheOffNote": "Cache jest wyłączony w formularzu. Reguła VCL nie włączy zapisu, jeśli cache lub trasa jest wyłączona.",
|
||||||
|
"cacheGuideRfcNote": "Tryb RFC: no-cache z backendu wymaga walidacji przed użyciem, nawet przy dodatnim zapasowym TTL.",
|
||||||
|
"cacheGuideCompatNote": "Tryb zgodności: odpowiedź no-cache może korzystać z dodatniego zapasowego TTL bez public. Private/no-store/Set-Cookie nadal blokują zapis.",
|
||||||
|
"cacheGuideCompatZeroNote": "Tryb zgodności z TTL = 0: do rewalidacji no-cache potrzebny jest ETag/Last-Modified. Nie będzie świeżego HIT bez dodatniego TTL.",
|
||||||
|
"cacheGuideFreshnessTitle": "no-cache, TTL i grace",
|
||||||
|
"cacheGuideFreshnessText": "Przy włączonej zgodności Varnish i dodatnim zapasowym TTL odpowiedź Cache-Control: no-cache może dawać HIT bez public. Po wyłączeniu zgodności no-cache wymaga walidacji przed ponownym użyciem. Grace to osobny okres dopuszczalnej nieświeżości, a nie zapasowy TTL.",
|
||||||
|
"cacheGuideFreshnessWarning": "Nie oczekuj HIT dla private/no-store/Set-Cookie ani podczas BYPASS. To jawne nadpisanie RustProxy, a nie domyślne działanie Varnish VCL.",
|
||||||
|
"cacheGuideCookieTitle": "Cookie i return(hash)",
|
||||||
|
"cacheGuideCookieText": "Cookie domyślnie powoduje BYPASS. W trybie zgodności jawne return(hash) może dopuścić odpowiednie żądania; Cookie nadal trafia do backendu i rozdziela warianty cache. Wcześniej zatrzymaj cookies sesyjne przez return(pass).",
|
||||||
|
"cacheGuideCookieWarning": "unset req.http.Cookie usuwa WSZYSTKIE cookies, również z żądania przekazywanego do backendu. Zabezpieczenia Authorization i uwierzytelniania nadal obowiązują.",
|
||||||
|
"cacheGuideVaryTitle": "Vary i warianty cache",
|
||||||
|
"cacheGuideVaryText": "set/unset beresp.http.Vary zmienia warianty przed zapisem. set/unset resp.http.Vary modyfikuje tylko nagłówek dla klienta i nie poprawia już istniejącego klucza cache. Przypisanie zastępuje całą listę Vary.",
|
||||||
|
"cacheGuideVaryWarning": "Nie usuwaj wymaganego wymiaru Vary dla treści osobistych lub kodowanych. RustProxy może przywrócić Vary: Cookie dla wariantów cookies; opcja Ignore Vary: Cookie dla statycznych plików nadal wymaga public i innych warunków.",
|
||||||
|
"cacheGuideHeadersTitle": "Nagłówki set/unset",
|
||||||
|
"cacheGuideHeadersText": "beresp.http.* zmienia nagłówki backendu przed decyzją cache; resp.http.* zmienia tylko odpowiedź dla klienta. Usunięcie beresp.http.Cache-Control może zmienić możliwość cache’owania, natomiast usunięcie resp.http.Cache-Control już nie.",
|
||||||
|
"cacheGuideHeadersWarning": "Importer obsługuje stałe łańcuchy tekstowe; chronionych nagłówków transportu i treści nie można zmieniać. Usunięcie Set-Cookie ma osobną akcję backendową i jest niebezpieczne przy sesjach.",
|
||||||
|
"cacheGuideRequestTitle": "Nagłówki żądania i nadpisania zapisu",
|
||||||
|
"cacheGuideRequestText": "Bezpieczne set/unset req.http działają przed kolejnymi regułami, obliczeniem klucza i wysłaniem do backendu. beresp.uncacheable = false cofa wcześniejszą decyzję Nie zapisuj z reguł, ale nie omija private/no-store/Set-Cookie backendu.",
|
||||||
|
"cacheGuideRequestWarning": "Authorization, Cookie (poza osobnym unset), Cache-Control oraz nagłówki transportowe i tożsamości są chronione. Złożone modyfikacje req.url zgłaszają ostrzeżenie zamiast niepewnej konwersji. Sprawdź ostrzeżenia importu.",
|
||||||
|
"cacheGuideStagesTitle": "Etapy VCL i pierwszeństwo reguł",
|
||||||
|
"cacheGuideStagesText": "vcl_recv obsługuje pass/hash, bezpieczne set/unset req.http i zmiany żądania; vcl_hash wybrane hash_data(req.http.X); vcl_backend_response TTL, grace, beresp.uncacheable true/false i nagłówki backendu; vcl_deliver zmienia nagłówki końcowe, także przy HIT lub BYPASS.",
|
||||||
|
"cacheGuidePrecedenceText": "Reguły per-vhost są wykonywane przed globalnymi. Lokalne zmiany mają pierwszeństwo przy konfliktach obsługiwanych ustawień i nagłówków; reguły globalne można wyłączyć dla vhosta. Import VCL tworzy reguły graficzne – przejrzyj ostrzeżenia i kolejność przed zapisem.",
|
||||||
|
"cacheGuideUnsupportedText": "To nie jest pełny interpreter Varnisha: etapy vcl_hit/vcl_miss/vcl_pass, własne sub/call, VMOD, ACL w wyrażeniach, beresp.keep, hit-for-miss/pass, restart, retry, synth i purge nie są wykonywane jako VCL.",
|
||||||
|
"cacheGuideDiagnoseTitle": "Dlaczego nie ma HIT?",
|
||||||
|
"cacheGuideDiagnoseText": "Włącz X-Cache i szczegółowe przyczyny, a na czas diagnozy wyłącz Only on HIT. Wykonaj dwa identyczne GET przez curl (bez twardego odświeżania przeglądarki) i porównaj wynik oraz nagłówki backendu.",
|
||||||
|
"cacheGuideDiagnoseReasons": "BYPASS zwykle oznacza wykluczenie żądania (Cookie, Authorization, trasa lub query). MISS oznacza kontakt z backendem, ale nie potwierdza zapisu odpowiedzi. Sprawdź X-Cache-Reason, Cache-Control, Set-Cookie, Vary i Age.",
|
||||||
|
"cacheGuideScope": "Te reguły VCL dotyczą vhostów reverse proxy; nie wykonują się w panelu administracyjnym ani na wszystkich źródłach Web Server. Najpierw testuj na vhoście nieprodukcyjnym.",
|
||||||
|
"cacheGuideDocsVcl": "Obsługiwana składnia VCL i ograniczenia",
|
||||||
|
"cacheGuideDocsCache": "Polityka HTTP cache i diagnostyka",
|
||||||
"cacheRulesHelp": "Reguły warunkowe w duchu VCL Varnisha: decydują, co trafia do cache, jak budowany jest klucz, jak długo obiekt żyje i jakie nagłówki dostaje klient. Reguły żądania działają przed wyszukaniem w cache, reguły odpowiedzi na odpowiedzi backendu, reguły wysyłki na każdej odpowiedzi. Reguły vhosta (edytor vhosta → Cache) działają przed tymi globalnymi. Zapisywane przyciskiem zapisu ustawień cache.",
|
"cacheRulesHelp": "Reguły warunkowe w duchu VCL Varnisha: decydują, co trafia do cache, jak budowany jest klucz, jak długo obiekt żyje i jakie nagłówki dostaje klient. Reguły żądania działają przed wyszukaniem w cache, reguły odpowiedzi na odpowiedzi backendu, reguły wysyłki na każdej odpowiedzi. Reguły vhosta (edytor vhosta → Cache) działają przed tymi globalnymi. Zapisywane przyciskiem zapisu ustawień cache.",
|
||||||
"vhCacheRulesTitle": "Reguły cache tego vhosta",
|
"vhCacheRulesTitle": "Reguły cache tego vhosta",
|
||||||
"vhCacheRulesHelp": "Działają przed regułami globalnymi z Ustawienia → Cache → Reguły. Gdy obie ustawiają to samo (TTL, grace, pominięcie cache, brak zapisu), wygrywa reguła vhosta.",
|
"vhCacheRulesHelp": "Działają przed regułami globalnymi z Ustawienia → Cache → Reguły. Gdy obie ustawiają to samo (TTL, grace, pominięcie cache, brak zapisu), wygrywa reguła vhosta.",
|
||||||
@@ -3382,7 +3423,7 @@
|
|||||||
"cacheRulesImportHelp": "Wklej VCL (vcl_recv, vcl_hash, vcl_backend_response, vcl_deliver). Obsługiwane instrukcje staną się regułami, resztę wypiszemy jako ostrzeżenia. Zaimportowane reguły zostaną dodane poniżej i zapisane z formularzem.",
|
"cacheRulesImportHelp": "Wklej VCL (vcl_recv, vcl_hash, vcl_backend_response, vcl_deliver). Obsługiwane instrukcje staną się regułami, resztę wypiszemy jako ostrzeżenia. Zaimportowane reguły zostaną dodane poniżej i zapisane z formularzem.",
|
||||||
"cacheRulesImportRun": "Zamień na reguły",
|
"cacheRulesImportRun": "Zamień na reguły",
|
||||||
"cacheRulesImportDone": "Zaimportowano reguł: {count}. Sprawdź je i zapisz.",
|
"cacheRulesImportDone": "Zaimportowano reguł: {count}. Sprawdź je i zapisz.",
|
||||||
"cacheRulesImportWarnings": "Nie zaimportowano:",
|
"cacheRulesImportWarnings": "Ostrzeżenia importu: część instrukcji pominięto lub przetłumaczono w przybliżeniu:",
|
||||||
"cacheRulesVclPreview": "Podgląd VCL (tylko do odczytu)",
|
"cacheRulesVclPreview": "Podgląd VCL (tylko do odczytu)",
|
||||||
"cacheRulesGlobalApply": "W tym vhoście działają też reguły globalne ({count}): {names}.",
|
"cacheRulesGlobalApply": "W tym vhoście działają też reguły globalne ({count}): {names}.",
|
||||||
"cacheRulesGlobalSkipped": "Reguły globalne ({count}) są w tym vhoście ignorowane.",
|
"cacheRulesGlobalSkipped": "Reguły globalne ({count}) są w tym vhoście ignorowane.",
|
||||||
@@ -3411,6 +3452,7 @@
|
|||||||
"cacheRulesResultNotStored": "Nie zapisane ({reason})",
|
"cacheRulesResultNotStored": "Nie zapisane ({reason})",
|
||||||
"cacheRulesResultPass": "Pominięcie cache ({reason})",
|
"cacheRulesResultPass": "Pominięcie cache ({reason})",
|
||||||
"cacheRulesResultRequest": "Reguły żądania",
|
"cacheRulesResultRequest": "Reguły żądania",
|
||||||
|
"cacheRulesResultRequestHeaders": "Zmiany nagłówków żądania",
|
||||||
"cacheRulesResultResponse": "Reguły odpowiedzi",
|
"cacheRulesResultResponse": "Reguły odpowiedzi",
|
||||||
"cacheRulesResultDeliver": "Nagłówki wysyłki",
|
"cacheRulesResultDeliver": "Nagłówki wysyłki",
|
||||||
"cacheRulesResultKey": "Klucz cache",
|
"cacheRulesResultKey": "Klucz cache",
|
||||||
@@ -3478,19 +3520,27 @@
|
|||||||
"cacheRuleOpCidr": "należy do",
|
"cacheRuleOpCidr": "należy do",
|
||||||
"cacheRuleAction": "Akcja",
|
"cacheRuleAction": "Akcja",
|
||||||
"cacheRuleActionPass": "Pomiń cache (pass)",
|
"cacheRuleActionPass": "Pomiń cache (pass)",
|
||||||
|
"cacheRuleActionLookup": "Dopuść cache żądania z Cookie (hash)",
|
||||||
"cacheRuleActionStripCookies": "Usuń ciasteczka",
|
"cacheRuleActionStripCookies": "Usuń ciasteczka",
|
||||||
"cacheRuleActionStripQuery": "Usuń parametry zapytania",
|
"cacheRuleActionStripQuery": "Usuń parametry zapytania",
|
||||||
|
"cacheRuleActionSetRequestHeader": "Ustaw nagłówek żądania",
|
||||||
|
"cacheRuleActionRemoveRequestHeader": "Usuń nagłówek żądania",
|
||||||
"cacheRuleActionHashHeader": "Dodaj nagłówek do klucza",
|
"cacheRuleActionHashHeader": "Dodaj nagłówek do klucza",
|
||||||
"cacheRuleActionHashCookie": "Dodaj ciasteczko do klucza",
|
"cacheRuleActionHashCookie": "Dodaj ciasteczko do klucza",
|
||||||
"cacheRuleActionTtl": "Ustaw TTL",
|
"cacheRuleActionTtl": "Ustaw TTL",
|
||||||
"cacheRuleActionGrace": "Ustaw grace",
|
"cacheRuleActionGrace": "Ustaw grace",
|
||||||
"cacheRuleActionNoStore": "Nie zapisuj",
|
"cacheRuleActionNoStore": "Nie zapisuj",
|
||||||
|
"cacheRuleActionAllowStore": "Zezwól na zapis (respektuj backend)",
|
||||||
"cacheRuleActionIgnoreCacheControl": "Ignoruj Cache-Control backendu",
|
"cacheRuleActionIgnoreCacheControl": "Ignoruj Cache-Control backendu",
|
||||||
"cacheRuleActionStripSetCookie": "Usuń Set-Cookie",
|
"cacheRuleActionStripSetCookie": "Usuń Set-Cookie",
|
||||||
|
"cacheRuleActionSetBackendHeader": "Ustaw nagłówek odpowiedzi backendu",
|
||||||
|
"cacheRuleActionRemoveBackendHeader": "Usuń nagłówek odpowiedzi backendu",
|
||||||
"cacheRuleActionSetHeader": "Ustaw nagłówek odpowiedzi",
|
"cacheRuleActionSetHeader": "Ustaw nagłówek odpowiedzi",
|
||||||
"cacheRuleActionRemoveHeader": "Usuń nagłówek odpowiedzi",
|
"cacheRuleActionRemoveHeader": "Usuń nagłówek odpowiedzi",
|
||||||
"cacheRuleActionHelpPass": "Żądanie idzie prosto do backendu; nic nie jest czytane z cache ani do niego zapisywane.",
|
"cacheRuleActionHelpPass": "Żądanie idzie prosto do backendu; nic nie jest czytane z cache ani do niego zapisywane.",
|
||||||
|
"cacheRuleActionHelpLookup": "Dopuść żądania z Cookie do cache w trybie zgodności z Varnishem (return(hash)); ciasteczka sesyjne powinny pasować do wcześniejszej reguły pass. Pozostałe Cookie stanowią część wariantu cache.",
|
||||||
"cacheRuleActionHelpNoStore": "Odpowiedź jest wysyłana, ale nie trafia do cache.",
|
"cacheRuleActionHelpNoStore": "Odpowiedź jest wysyłana, ale nie trafia do cache.",
|
||||||
|
"cacheRuleActionHelpAllowStore": "Cofa wcześniejsze Nie zapisuj z VCL. Nie ignoruje private/no-store backendu, Set-Cookie ani innych zabezpieczeń.",
|
||||||
"cacheRuleActionHelpIgnoreCacheControl": "Zapisuje mimo no-cache, private lub no-store z backendu (TTL z akcji TTL albo domyślny). Odpowiedzi z Set-Cookie wymagają też Usuń Set-Cookie.",
|
"cacheRuleActionHelpIgnoreCacheControl": "Zapisuje mimo no-cache, private lub no-store z backendu (TTL z akcji TTL albo domyślny). Odpowiedzi z Set-Cookie wymagają też Usuń Set-Cookie.",
|
||||||
"cacheRuleActionHelpStripSetCookie": "Usuwa Set-Cookie z odpowiedzi backendu (zapisywanej i wysyłanej), jak unset beresp.http.Set-Cookie.",
|
"cacheRuleActionHelpStripSetCookie": "Usuwa Set-Cookie z odpowiedzi backendu (zapisywanej i wysyłanej), jak unset beresp.http.Set-Cookie.",
|
||||||
"cacheRuleKeepCookies": "zostaw ciasteczka (puste = usuń wszystkie)",
|
"cacheRuleKeepCookies": "zostaw ciasteczka (puste = usuń wszystkie)",
|
||||||
@@ -3701,6 +3751,23 @@
|
|||||||
"alertSettingsCertificateOrder": "Próg błędu musi mieć mniej dni niż próg ostrzeżenia.",
|
"alertSettingsCertificateOrder": "Próg błędu musi mieć mniej dni niż próg ostrzeżenia.",
|
||||||
"alertSettingsPercentOrder": "Próg błędu musi być wyższy niż próg ostrzeżenia.",
|
"alertSettingsPercentOrder": "Próg błędu musi być wyższy niż próg ostrzeżenia.",
|
||||||
"vhCacheStaticVaryCookie": "Ignoruj Vary: Cookie dla publicznych plików statycznych (dziedzicz/wł./wył.)",
|
"vhCacheStaticVaryCookie": "Ignoruj Vary: Cookie dla publicznych plików statycznych (dziedzicz/wł./wył.)",
|
||||||
"cacheStaticVaryCookie": "Ignoruj Vary: Cookie dla publicznych plików statycznych"
|
"cacheStaticVaryCookie": "Ignoruj Vary: Cookie dla publicznych plików statycznych",
|
||||||
|
"cacheRulesImportPending": "{count} reguł czeka na akceptację. Sprawdź wszystkie ostrzeżenia przed ich dodaniem; ustawienia nie zostały zapisane.",
|
||||||
|
"cacheRulesImportApplyPartial": "Dodaj częściowy import (po sprawdzeniu)",
|
||||||
|
"cacheRulesImportNoActions": "Nie zaimportowano wykonywalnych reguł cache. Kod może zawierać tylko domyślne elementy klucza lub nieobsługiwane instrukcje.",
|
||||||
|
"cacheGuideUncacheableDifference": "W RustProxy beresp.uncacheable = false cofa tylko wcześniejszy zakaz zapisu z reguły cache — inaczej niż w Varnishu. Nagłówki private/no-store i Set-Cookie nadal blokują zapis, chyba że zaufana reguła świadomie je nadpisze.",
|
||||||
|
"cacheGuideBuiltInHash": "hash_data(req.url) i hash_data(req.http.Host) są już uwzględnione w wewnętrznym kluczu cache. vcl_hash może dodać dodatkowy nagłówek req.http.*, ale nie tworzy automatycznie odpowiedniego nagłówka Vary.",
|
||||||
|
"cacheGuideStatusRestriction": "RustProxy zapisuje obecnie tylko odpowiedzi HTTP 200. Reguła TTL dla 404/301 nie uruchomi cache tych statusów; usunięto szablon 404, aby nie sugerował inaczej.",
|
||||||
|
"cacheGuideVclPreviewWarning": "Eksport VCL to podgląd, a nie bezstratny zapis konfiguracji. Gdy importer zwraca ostrzeżenia, reguły zostaną dodane dopiero po wyraźnej akceptacji częściowego wyniku. Edycja kodu lub zamknięcie importera anuluje oczekujący import.",
|
||||||
|
"cacheRulesTesterRequestTitle": "Żądanie HTTP",
|
||||||
|
"cacheRulesTesterResponseTitle": "Odpowiedź backendu",
|
||||||
|
"cacheRulesTesterHelpGlobal": "Symulacja: niezapisane reguły globalne i zapisane reguły wybranego vhosta. Bez ruchu do backendu i zmiany liczników.",
|
||||||
|
"cacheRulesTesterHelpVhost": "Symulacja: niezapisane reguły tego vhosta i zapisane globalne (chyba że je wyłączysz). Pozostałe niezapisane opcje cache nie są symulowane.",
|
||||||
|
"cacheGuideContextGlobal": "Reguły globalne",
|
||||||
|
"cacheGuideContextVhost": "Vhost",
|
||||||
|
"cacheGuideContextDocker": "Docker vhost",
|
||||||
|
"cacheGuideScopeGlobal": "Przykład VCL zostanie wstawiony do globalnego importera. Tester może dodatkowo uwzględnić zapisane reguły wybranego vhosta.",
|
||||||
|
"cacheGuideScopeVhost": "Przykład VCL zostanie wstawiony tylko do importera tego vhosta. Reguły vhosta mają pierwszeństwo przed zapisanymi globalnymi; można też wyłączyć globalne. TTL pokazany wyżej jest ustawieniem globalnym.",
|
||||||
|
"cacheGuideScopeDocker": "Przykład VCL zostanie wstawiony tylko do importera tego Docker vhosta. Reguły globalne działają tak samo jak dla zwykłych vhostów, o ile nie są wyłączone. TTL pokazany wyżej jest ustawieniem globalnym."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +145,7 @@ async fn cache_rules_test(
|
|||||||
client_ip,
|
client_ip,
|
||||||
};
|
};
|
||||||
let request_outcome = rules.evaluate_request(&request, false);
|
let request_outcome = rules.evaluate_request(&request, false);
|
||||||
|
request_outcome.apply_headers(&mut headers);
|
||||||
request_outcome.rewrite_cookies(&mut headers);
|
request_outcome.rewrite_cookies(&mut headers);
|
||||||
let query = match request_outcome.rewrite_query(uri.query()) {
|
let query = match request_outcome.rewrite_query(uri.query()) {
|
||||||
Some(rewritten) => rewritten,
|
Some(rewritten) => rewritten,
|
||||||
@@ -161,7 +162,10 @@ async fn cache_rules_test(
|
|||||||
} else if !settings.enabled {
|
} else if !settings.enabled {
|
||||||
Some("cache_disabled")
|
Some("cache_disabled")
|
||||||
} else {
|
} else {
|
||||||
crate::cache::request_policy(&method, &headers, true, &path, query.is_some(), &settings)
|
crate::cache::request_policy_with_vcl_cookie(
|
||||||
|
&method, &headers, true, &path, query.is_some(), &settings,
|
||||||
|
request_outcome.lookup.is_some(),
|
||||||
|
)
|
||||||
.bypass_reason()
|
.bypass_reason()
|
||||||
};
|
};
|
||||||
let mut response_value = Value::Null;
|
let mut response_value = Value::Null;
|
||||||
@@ -175,9 +179,7 @@ async fn cache_rules_test(
|
|||||||
})?;
|
})?;
|
||||||
let mut response_headers = cache_rule_headers(&response.headers)?;
|
let mut response_headers = cache_rule_headers(&response.headers)?;
|
||||||
let outcome = rules.evaluate_response(&request, status, &response_headers, false);
|
let outcome = rules.evaluate_response(&request, status, &response_headers, false);
|
||||||
if outcome.overrides.strip_set_cookie {
|
outcome.overrides.apply_headers(&mut response_headers);
|
||||||
response_headers.remove(http::header::SET_COOKIE);
|
|
||||||
}
|
|
||||||
let plan = if request_policy.is_none() {
|
let plan = if request_policy.is_none() {
|
||||||
crate::cache::plan_with(
|
crate::cache::plan_with(
|
||||||
status,
|
status,
|
||||||
@@ -220,6 +222,8 @@ async fn cache_rules_test(
|
|||||||
"matched": request_outcome.matched,
|
"matched": request_outcome.matched,
|
||||||
"overridden": request_outcome.overridden,
|
"overridden": request_outcome.overridden,
|
||||||
"pass": request_outcome.pass,
|
"pass": request_outcome.pass,
|
||||||
|
"lookup": request_outcome.lookup,
|
||||||
|
"header_edits": request_outcome.header_edits,
|
||||||
"target": target,
|
"target": target,
|
||||||
"cookie": headers.get(http::header::COOKIE).and_then(|v| v.to_str().ok()),
|
"cookie": headers.get(http::header::COOKIE).and_then(|v| v.to_str().ok()),
|
||||||
"variant": request_outcome.hash,
|
"variant": request_outcome.hash,
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ pub(super) static READER_DOCUMENTS: &[(&str, &str, &str)] = &[
|
|||||||
reader_doc!("docs/WEB_SERVER.md", "guides"),
|
reader_doc!("docs/WEB_SERVER.md", "guides"),
|
||||||
reader_doc!("docs/PHP_FPM.md", "guides"),
|
reader_doc!("docs/PHP_FPM.md", "guides"),
|
||||||
reader_doc!("docs/CACHE.md", "guides"),
|
reader_doc!("docs/CACHE.md", "guides"),
|
||||||
|
reader_doc!("docs/VCL.md", "guides"),
|
||||||
reader_doc!("docs/RESPONSE_DELIVERY.md", "guides"),
|
reader_doc!("docs/RESPONSE_DELIVERY.md", "guides"),
|
||||||
reader_doc!("docs/TRANSPORT.md", "guides"),
|
reader_doc!("docs/TRANSPORT.md", "guides"),
|
||||||
reader_doc!("docs/STREAMS.md", "guides"),
|
reader_doc!("docs/STREAMS.md", "guides"),
|
||||||
|
|||||||
+11
-5
@@ -2,7 +2,7 @@
|
|||||||
"openapi": "3.0.3",
|
"openapi": "3.0.3",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "RustProxy Administration API",
|
"title": "RustProxy Administration API",
|
||||||
"version": "0.38.7",
|
"version": "0.38.8",
|
||||||
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust. The API also permits explicitly scoped GeneralApiBearer tokens on a narrow route allowlist, with RO/RW and source CIDR checks; API-token management and Prometheus-token management are browser-session-only."
|
"description": "Administration API for the active panel origin. Sign in through the panel; the same-origin HttpOnly cookie authenticates all private operations. Mutations also require the exact Origin, X-RustProxy-Request: 1 and a session-bound X-CSRF-Token. Loopback HTTP is the default; Settings can enable HTTPS before using a non-loopback administration bind. This document contains no live configuration or credentials. Object schemas marked extensible are summaries: full configuration validation is authoritative in Rust. The API also permits explicitly scoped GeneralApiBearer tokens on a narrow route allowlist, with RO/RW and source CIDR checks; API-token management and Prometheus-token management are browser-session-only."
|
||||||
},
|
},
|
||||||
"servers": [
|
"servers": [
|
||||||
@@ -8770,7 +8770,7 @@
|
|||||||
},
|
},
|
||||||
"CacheRule": {
|
"CacheRule": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "Cache rule (since 0.37.1). Request rules run before the cache lookup (vcl_recv/vcl_hash), response rules on a backend response (vcl_backend_response), deliver rules on every response sent to the client (vcl_deliver). Vhost rules run before global rules; for TTL, grace, pass and no_store the first matching rule wins.",
|
"description": "Cache rule (since 0.37.1, extended in 0.38.8). Request rules run in vcl_recv then vcl_hash after return(hash); response rules run before origin cache admission; deliver rules run before sending headers. Vhost rules precede global rules and own their mutated header fields. Later assignments in the same scope take precedence unless a terminal return stops the stage. VCL import is a supported subset and returns warnings for unsupported operations.",
|
||||||
"required": [
|
"required": [
|
||||||
"id",
|
"id",
|
||||||
"actions"
|
"actions"
|
||||||
@@ -8856,13 +8856,14 @@
|
|||||||
},
|
},
|
||||||
"actions": {
|
"actions": {
|
||||||
"type": "array",
|
"type": "array",
|
||||||
"minItems": 1,
|
"minItems": 0,
|
||||||
"maxItems": 16,
|
"maxItems": 16,
|
||||||
"items": {
|
"items": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"description": "type: pass, strip_cookies{keep}, strip_query{params,keep_only}, hash_header{name}, hash_cookie{name} (request); ttl{seconds}, grace{seconds}, no_store, ignore_cache_control, strip_set_cookie (response); set_header{name,value}, default_header{name,value} (only when the response lacks the header, since 0.37.2), remove_header{name} (deliver; deliver rules apply to every response of the vhost, also when caching is off).",
|
"description": "type: pass, lookup (VCL return(hash), Cookie exception in Varnish-compatible mode), strip_cookies{keep}, strip_query{params,keep_only}, hash_header{name}, hash_cookie{name}, set_request_header{name,value}, remove_request_header{name} (request; protected auth/cache/framing headers cannot be changed); ttl{seconds}, grace{seconds}, no_store, allow_store (reverses rule no_store only; origin restrictions remain), ignore_cache_control, strip_set_cookie, set_backend_header{name,value}, remove_backend_header{name} (response, applied before cacheability and forwarded headers); set_header{name,value}, default_header{name,value}, remove_header{name} (deliver, including cache-disabled responses).",
|
||||||
"additionalProperties": true
|
"additionalProperties": true
|
||||||
}
|
},
|
||||||
|
"description": "Zero actions allowed only with stop=true (terminal return)."
|
||||||
},
|
},
|
||||||
"stop": {
|
"stop": {
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
@@ -8873,6 +8874,11 @@
|
|||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
"description": "Global rules only: limit to these vhost ids (empty = all)."
|
"description": "Global rules only: limit to these vhost ids (empty = all)."
|
||||||
|
},
|
||||||
|
"hash_stage": {
|
||||||
|
"type": "boolean",
|
||||||
|
"default": false,
|
||||||
|
"description": "Run this request-stage rule in vcl_hash, after vcl_recv. Imported VCL sets this automatically."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
+144
-39
@@ -18,11 +18,11 @@ window.rustProxyCacheRules = (() => {
|
|||||||
response_header: { ops: ["exists", "equals", "contains", "regex"], name: true, stages: ["response", "deliver"] },
|
response_header: { ops: ["exists", "equals", "contains", "regex"], name: true, stages: ["response", "deliver"] },
|
||||||
};
|
};
|
||||||
const ACTIONS = {
|
const ACTIONS = {
|
||||||
request: ["pass", "strip_cookies", "strip_query", "hash_header", "hash_cookie"],
|
request: ["pass", "lookup", "strip_cookies", "strip_query", "hash_header", "hash_cookie", "set_request_header", "remove_request_header"],
|
||||||
response: ["ttl", "grace", "no_store", "ignore_cache_control", "strip_set_cookie"],
|
response: ["ttl", "grace", "no_store", "allow_store", "ignore_cache_control", "strip_set_cookie", "set_backend_header", "remove_backend_header"],
|
||||||
deliver: ["set_header", "default_header", "remove_header"],
|
deliver: ["set_header", "default_header", "remove_header"],
|
||||||
};
|
};
|
||||||
const ASPECTS = { pass: "pass", ttl: "ttl", grace: "grace", no_store: "store" };
|
const ASPECTS = { pass: "request_routing", lookup: "request_routing", strip_cookies: "request_cookies", strip_query: "request_query", ttl: "ttl", grace: "grace", no_store: "store", allow_store: "store" };
|
||||||
const tk = (prefix, value) => t(`${prefix}${String(value).split("_").map(part => part[0].toUpperCase() + part.slice(1)).join("")}`);
|
const tk = (prefix, value) => t(`${prefix}${String(value).split("_").map(part => part[0].toUpperCase() + part.slice(1)).join("")}`);
|
||||||
const fieldLabel = field => tk("cacheRuleField", field);
|
const fieldLabel = field => tk("cacheRuleField", field);
|
||||||
const opLabel = op => tk("cacheRuleOp", op);
|
const opLabel = op => tk("cacheRuleOp", op);
|
||||||
@@ -40,10 +40,11 @@ window.rustProxyCacheRules = (() => {
|
|||||||
return { id, name: t("cacheRuleNewName"), enabled: true, stage, match: "all", conditions: [], actions: [{ type: ACTIONS[stage][0] }], stop: false, vhosts: [] };
|
return { id, name: t("cacheRuleNewName"), enabled: true, stage, match: "all", conditions: [], actions: [{ type: ACTIONS[stage][0] }], stop: false, vhosts: [] };
|
||||||
}
|
}
|
||||||
function normalize(rule) {
|
function normalize(rule) {
|
||||||
return { id: rule.id, name: rule.name || "", enabled: rule.enabled !== false, stage: rule.stage || "request", match: rule.match || "all", conditions: (rule.conditions || []).map(c => ({ ...c, values: [...(c.values || [])] })), actions: (rule.actions || []).map(a => ({ ...a })), stop: !!rule.stop, vhosts: [...(rule.vhosts || [])] };
|
return { id: rule.id, name: rule.name || "", enabled: rule.enabled !== false, stage: rule.stage || "request", match: rule.match || "all", conditions: (rule.conditions || []).map(c => ({ ...c, values: [...(c.values || [])] })), actions: (rule.actions || []).map(a => ({ ...a })), stop: !!rule.stop, hash_stage: !!rule.hash_stage, vhosts: [...(rule.vhosts || [])] };
|
||||||
}
|
}
|
||||||
function clean(rule, global) {
|
function clean(rule, global) {
|
||||||
const out = { id: rule.id, name: rule.name, enabled: rule.enabled, stage: rule.stage, match: rule.match, conditions: rule.conditions.map(c => { const item = { field: c.field, operator: c.operator, values: c.operator === "exists" ? [] : c.values }; if (FIELDS[c.field]?.name) item.name = c.name || ""; if (c.negate) item.negate = true; return item; }), actions: rule.actions.map(a => ({ ...a })), stop: rule.stop };
|
const out = { id: rule.id, name: rule.name, enabled: rule.enabled, stage: rule.stage, match: rule.match, conditions: rule.conditions.map(c => { const item = { field: c.field, operator: c.operator, values: c.operator === "exists" ? [] : c.values }; if (FIELDS[c.field]?.name) item.name = c.name || ""; if (c.negate) item.negate = true; return item; }), actions: rule.actions.map(a => ({ ...a })), stop: rule.stop };
|
||||||
|
if (rule.hash_stage) out.hash_stage = true;
|
||||||
if (global && rule.vhosts.length) out.vhosts = rule.vhosts;
|
if (global && rule.vhosts.length) out.vhosts = rule.vhosts;
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
@@ -81,15 +82,21 @@ window.rustProxyCacheRules = (() => {
|
|||||||
return rule.actions.map(a => {
|
return rule.actions.map(a => {
|
||||||
switch (a.type) {
|
switch (a.type) {
|
||||||
case "pass": return "return (pass);";
|
case "pass": return "return (pass);";
|
||||||
|
case "lookup": return rule.hash_stage ? "return (lookup);" : "return (hash);";
|
||||||
case "strip_cookies": return a.keep?.length ? `# keep only cookies: ${a.keep.join(", ")}\nset req.http.Cookie = regsuball(req.http.Cookie, "(^|;\\s*)(?!(${a.keep.map(reEsc).join("|")})=)[^;=]+=[^;]*", "");` : "unset req.http.Cookie;";
|
case "strip_cookies": return a.keep?.length ? `# keep only cookies: ${a.keep.join(", ")}\nset req.http.Cookie = regsuball(req.http.Cookie, "(^|;\\s*)(?!(${a.keep.map(reEsc).join("|")})=)[^;=]+=[^;]*", "");` : "unset req.http.Cookie;";
|
||||||
case "strip_query": return a.keep_only ? `# keep only query parameters: ${(a.params || []).join(", ")}` : (a.params?.length ? `set req.url = regsuball(req.url, "([?&])(${a.params.map(p => globRe(p).replace(/\.\*/g, "[^=&]*")).join("|")})=[^&]*", "\\1");` : `set req.url = regsub(req.url, "\\?.*$", "");`);
|
case "strip_query": return a.keep_only ? `# keep only query parameters: ${(a.params || []).join(", ")}` : (a.params?.length ? `set req.url = regsuball(req.url, "([?&])(${a.params.map(p => globRe(p).replace(/\.\*/g, "[^=&]*")).join("|")})=[^&]*", "\\1");` : `set req.url = regsub(req.url, "\\?.*$", "");`);
|
||||||
case "hash_header": return `hash_data(req.http.${a.name});`;
|
case "hash_header": return `hash_data(req.http.${a.name});`;
|
||||||
case "hash_cookie": return `hash_data(regsub(req.http.Cookie, "^.*(?:^|;\\s*)${reEsc(a.name)}=([^;]*).*$", "\\1"));`;
|
case "hash_cookie": return `hash_data(regsub(req.http.Cookie, "^.*(?:^|;\\s*)${reEsc(a.name)}=([^;]*).*$", "\\1"));`;
|
||||||
|
case "set_request_header": return `set req.http.${a.name} = "${esc(a.value ?? "")}";`;
|
||||||
|
case "remove_request_header": return `unset req.http.${a.name};`;
|
||||||
case "ttl": return `set beresp.ttl = ${a.seconds ?? 0}s;`;
|
case "ttl": return `set beresp.ttl = ${a.seconds ?? 0}s;`;
|
||||||
case "grace": return `set beresp.grace = ${a.seconds ?? 0}s;`;
|
case "grace": return `set beresp.grace = ${a.seconds ?? 0}s;`;
|
||||||
case "no_store": return "set beresp.uncacheable = true;";
|
case "no_store": return "set beresp.uncacheable = true;";
|
||||||
|
case "allow_store": return "set beresp.uncacheable = false;";
|
||||||
case "ignore_cache_control": return "unset beresp.http.Cache-Control;";
|
case "ignore_cache_control": return "unset beresp.http.Cache-Control;";
|
||||||
case "strip_set_cookie": return "unset beresp.http.Set-Cookie;";
|
case "strip_set_cookie": return "unset beresp.http.Set-Cookie;";
|
||||||
|
case "set_backend_header": return `set beresp.http.${a.name} = "${esc(a.value ?? "")}";`;
|
||||||
|
case "remove_backend_header": return `unset beresp.http.${a.name};`;
|
||||||
case "set_header": return `set resp.http.${a.name} = "${esc(a.value ?? "")}";`;
|
case "set_header": return `set resp.http.${a.name} = "${esc(a.value ?? "")}";`;
|
||||||
case "remove_header": return `unset resp.http.${a.name};`;
|
case "remove_header": return `unset resp.http.${a.name};`;
|
||||||
case "default_header": return `if (!resp.http.${a.name}) { set resp.http.${a.name} = "${esc(a.value ?? "")}"; }`;
|
case "default_header": return `if (!resp.http.${a.name}) { set resp.http.${a.name} = "${esc(a.value ?? "")}"; }`;
|
||||||
@@ -99,20 +106,39 @@ window.rustProxyCacheRules = (() => {
|
|||||||
}
|
}
|
||||||
function ruleVcl(rule) {
|
function ruleVcl(rule) {
|
||||||
const lines = vclActions(rule).flatMap(line => line.split("\n"));
|
const lines = vclActions(rule).flatMap(line => line.split("\n"));
|
||||||
|
// An imported return(deliver) may be represented by stop=true and no actions.
|
||||||
|
// Preserve terminal control flow even when preceded by header/TTL actions.
|
||||||
|
if (rule.stop && !lines.some(line => /^return\s*\(/.test(line)))
|
||||||
|
lines.push(`return (${rule.stage === "request" ? (rule.hash_stage ? "lookup" : "hash") : "deliver"});`);
|
||||||
const conditions = rule.conditions.map(c => vclCondition(c, rule.stage));
|
const conditions = rule.conditions.map(c => vclCondition(c, rule.stage));
|
||||||
const joined = conditions.join(rule.match === "any" ? " ||\n " : " &&\n ");
|
const joined = conditions.join(rule.match === "any" ? " ||\n " : " &&\n ");
|
||||||
const body = lines.map(line => ` ${line}`).join("\n");
|
const body = lines.map(line => ` ${line}`).join("\n");
|
||||||
const head = `# ${rule.name || rule.id}${rule.enabled === false ? " (disabled)" : ""}${rule.vhosts?.length ? ` · vhosts: ${rule.vhosts.join(", ")}` : ""}`;
|
const head = `# ${rule.name || rule.id}${rule.enabled === false ? " (disabled)" : ""}${rule.vhosts?.length ? ` · vhosts: ${rule.vhosts.join(", ")}` : ""}`;
|
||||||
return conditions.length ? `${head}\nif (${joined}) {\n${body}\n}` : `${head}\n${body.replace(/^ {4}/gm, "")}`;
|
const limits = [];
|
||||||
|
if (rule.enabled === false) limits.push("This rule is DISABLED in RustProxy; the preview is not executable equivalently.");
|
||||||
|
if (rule.vhosts?.length) limits.push("Vhost targeting is stored in RustProxy config, not represented by VCL.");
|
||||||
|
if (rule.conditions.some(c => ["client_ip", "extension", "query", "cookie"].includes(c.field)))
|
||||||
|
limits.push("One or more graphical conditions have no guaranteed VCL import round-trip.");
|
||||||
|
if (rule.actions.some(a => ["hash_cookie", "strip_query", "strip_cookies", "default_header", "ignore_cache_control"].includes(a.type)))
|
||||||
|
limits.push("One or more graphical actions are only approximated in this VCL display.");
|
||||||
|
const notes = limits.map(limit => `# PREVIEW LIMITATION: ${limit}`).join("\n");
|
||||||
|
const description = notes ? `${head}\n${notes}` : head;
|
||||||
|
return conditions.length ? `${description}\nif (${joined}) {\n${body}\n}` : `${description}\n${body.replace(/^ {4}/gm, "")}`;
|
||||||
}
|
}
|
||||||
function exportVcl(rules) {
|
function exportVcl(rules) {
|
||||||
const subs = { request: "vcl_recv", response: "vcl_backend_response", deliver: "vcl_deliver" };
|
const subs = { request: "vcl_recv", response: "vcl_backend_response", deliver: "vcl_deliver" };
|
||||||
const blocks = ["vcl 4.1;", "# Generated by RustProxy cache rules (read-only preview)"];
|
const blocks = [
|
||||||
|
"vcl 4.1;",
|
||||||
|
"# RustProxy DISPLAY PREVIEW, not a lossless VCL backup or a deployable Varnish config.",
|
||||||
|
"# Source of truth: saved graphical rules. Import supports only the documented subset.",
|
||||||
|
"# Some rules (client IP, cookie allowlists, hash_cookie, disabled rules and other actions)",
|
||||||
|
"# have no matching VCL importer syntax. Check Rules -> Cache & VCL guide."
|
||||||
|
];
|
||||||
const indent = text => text.replace(/^/gm, " ");
|
const indent = text => text.replace(/^/gm, " ");
|
||||||
for (const stage of STAGES) {
|
for (const stage of STAGES) {
|
||||||
const items = rules.filter(rule => rule.stage === stage);
|
const items = rules.filter(rule => rule.stage === stage);
|
||||||
const main = items.map(rule => ({ ...rule, actions: rule.actions.filter(a => !a.type.startsWith("hash_")) })).filter(rule => rule.actions.length);
|
const main = items.filter(rule => !rule.hash_stage).map(rule => ({ ...rule, actions: rule.actions.filter(a => !a.type.startsWith("hash_")) })).filter(rule => rule.actions.length || rule.stop);
|
||||||
const hash = items.map(rule => ({ ...rule, actions: rule.actions.filter(a => a.type.startsWith("hash_")) })).filter(rule => rule.actions.length);
|
const hash = items.map(rule => ({ ...rule, actions: rule.hash_stage ? rule.actions : rule.actions.filter(a => a.type.startsWith("hash_")) })).filter(rule => (rule.actions.length || (rule.stop && rule.hash_stage)) && stage === "request");
|
||||||
if (main.length) blocks.push(`\nsub ${subs[stage]} {\n${main.map(rule => indent(ruleVcl(rule))).join("\n\n")}\n}`);
|
if (main.length) blocks.push(`\nsub ${subs[stage]} {\n${main.map(rule => indent(ruleVcl(rule))).join("\n\n")}\n}`);
|
||||||
if (hash.length) blocks.push(`\nsub vcl_hash {\n${hash.map(rule => indent(ruleVcl(rule))).join("\n\n")}\n}`);
|
if (hash.length) blocks.push(`\nsub vcl_hash {\n${hash.map(rule => indent(ruleVcl(rule))).join("\n\n")}\n}`);
|
||||||
}
|
}
|
||||||
@@ -122,8 +148,8 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const actions = rule.actions.map(a => {
|
const actions = rule.actions.map(a => {
|
||||||
if (a.type === "ttl" || a.type === "grace") return `${actionLabel(a.type)} ${fmtDuration(a.seconds)}`;
|
if (a.type === "ttl" || a.type === "grace") return `${actionLabel(a.type)} ${fmtDuration(a.seconds)}`;
|
||||||
if (a.type === "strip_query") return `${actionLabel(a.type)}${a.params?.length ? `: ${a.params.join(", ")}` : ""}`;
|
if (a.type === "strip_query") return `${actionLabel(a.type)}${a.params?.length ? `: ${a.params.join(", ")}` : ""}`;
|
||||||
if (a.type === "set_header" || a.type === "default_header") return `${actionLabel(a.type)}: ${a.name || "-"}${a.value ? ` = ${a.value}` : ""}`;
|
if (a.type === "set_header" || a.type === "default_header" || a.type === "set_backend_header" || a.type === "set_request_header") return `${actionLabel(a.type)}: ${a.name || "-"}${a.value ? ` = ${a.value}` : ""}`;
|
||||||
if (a.type === "remove_header" || a.type === "hash_header" || a.type === "hash_cookie") return `${actionLabel(a.type)}: ${a.name || "-"}`;
|
if (a.type === "remove_header" || a.type === "remove_backend_header" || a.type === "remove_request_header" || a.type === "hash_header" || a.type === "hash_cookie") return `${actionLabel(a.type)}: ${a.name || "-"}`;
|
||||||
return actionLabel(a.type);
|
return actionLabel(a.type);
|
||||||
});
|
});
|
||||||
return actions.join(" · ");
|
return actions.join(" · ");
|
||||||
@@ -142,7 +168,8 @@ window.rustProxyCacheRules = (() => {
|
|||||||
tracking: () => [{ name: t("cacheRuleTplTracking"), stage: "request", match: "all", conditions: [], actions: [{ type: "strip_query", params: ["utm_*", "fbclid", "gclid", "msclkid", "mc_cid", "mc_eid", "_ga"] }] }],
|
tracking: () => [{ name: t("cacheRuleTplTracking"), stage: "request", match: "all", conditions: [], actions: [{ type: "strip_query", params: ["utm_*", "fbclid", "gclid", "msclkid", "mc_cid", "mc_eid", "_ga"] }] }],
|
||||||
api: () => [{ name: t("cacheRuleTplApi"), stage: "request", match: "all", conditions: [{ field: "path", operator: "prefix", values: ["/api/"] }], actions: [{ type: "pass" }] }],
|
api: () => [{ name: t("cacheRuleTplApi"), stage: "request", match: "all", conditions: [{ field: "path", operator: "prefix", values: ["/api/"] }], actions: [{ type: "pass" }] }],
|
||||||
language: () => [{ name: t("cacheRuleTplLanguage"), stage: "request", match: "all", conditions: [], actions: [{ type: "hash_cookie", name: "lang" }] }],
|
language: () => [{ name: t("cacheRuleTplLanguage"), stage: "request", match: "all", conditions: [], actions: [{ type: "hash_cookie", name: "lang" }] }],
|
||||||
notfound: () => [{ name: t("cacheRuleTplNotFound"), stage: "response", match: "all", conditions: [{ field: "status", operator: "equals", values: ["404"] }], actions: [{ type: "ttl", seconds: 60 }] }],
|
// No negative-cache template: the storage layer currently stores 200 only.
|
||||||
|
// A TTL rule matching 404 would appear enabled but could never yield HIT.
|
||||||
headers: () => [{ name: t("cacheRuleTplHeaders"), stage: "deliver", match: "all", conditions: [], actions: [{ type: "remove_header", name: "X-Powered-By" }] }],
|
headers: () => [{ name: t("cacheRuleTplHeaders"), stage: "deliver", match: "all", conditions: [], actions: [{ type: "remove_header", name: "X-Powered-By" }] }],
|
||||||
browser: () => [{ name: t("cacheRuleTplBrowser"), stage: "deliver", match: "all", conditions: [{ field: "extension", operator: "equals", values: ["css", "js", "mjs", "png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico", "woff", "woff2"] }, { field: "status", operator: "equals", values: ["200"] }], actions: [{ type: "set_header", name: "Cache-Control", value: "public, max-age=2592000" }] }],
|
browser: () => [{ name: t("cacheRuleTplBrowser"), stage: "deliver", match: "all", conditions: [{ field: "extension", operator: "equals", values: ["css", "js", "mjs", "png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico", "woff", "woff2"] }, { field: "status", operator: "equals", values: ["200"] }], actions: [{ type: "set_header", name: "Cache-Control", value: "public, max-age=2592000" }] }],
|
||||||
nobrowser: () => [{ name: t("cacheRuleTplNoBrowser"), stage: "deliver", match: "any", conditions: [{ field: "content_type", operator: "prefix", values: ["text/html"] }, { field: "path", operator: "prefix", values: ["/admin", "/account"] }], actions: [{ type: "set_header", name: "Cache-Control", value: "no-store" }] }],
|
nobrowser: () => [{ name: t("cacheRuleTplNoBrowser"), stage: "deliver", match: "any", conditions: [{ field: "content_type", operator: "prefix", values: ["text/html"] }, { field: "path", operator: "prefix", values: ["/admin", "/account"] }], actions: [{ type: "set_header", name: "Cache-Control", value: "no-store" }] }],
|
||||||
@@ -160,7 +187,7 @@ window.rustProxyCacheRules = (() => {
|
|||||||
for (const global of globals) {
|
for (const global of globals) {
|
||||||
if (global.stage !== local.stage) continue;
|
if (global.stage !== local.stage) continue;
|
||||||
const shared = [...aspects(normalize(global))].filter(aspect => mine.has(aspect));
|
const shared = [...aspects(normalize(global))].filter(aspect => mine.has(aspect));
|
||||||
if (shared.length) notes.push(t("cacheRulesOverrideNotice").replace("{vhost}", local.name || local.id).replace("{global}", global.name || global.id).replace("{aspects}", shared.map(aspect => t(`cacheRuleAspect${aspect[0].toUpperCase()}${aspect.slice(1)}`)).join(", ")));
|
if (shared.length) notes.push(t("cacheRulesOverrideNotice").replace("{vhost}", local.name || local.id).replace("{global}", global.name || global.id).replace("{aspects}", shared.map(aspect => ({ request_cookies: actionLabel("strip_cookies"), request_query: actionLabel("strip_query") })[aspect] || t(`cacheRuleAspect${aspect[0].toUpperCase()}${aspect.slice(1)}`)).join(", ")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return notes;
|
return notes;
|
||||||
@@ -221,7 +248,20 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const root = el("div", undefined, `cache-rules cache-rules-${scope}`);
|
const root = el("div", undefined, `cache-rules cache-rules-${scope}`);
|
||||||
const changed = () => { root.dispatchEvent(new Event("input", { bubbles: true })); options.onChange?.(); };
|
const changed = () => { root.dispatchEvent(new Event("input", { bubbles: true })); options.onChange?.(); };
|
||||||
const toolbar = el("div", undefined, "cache-rules-toolbar");
|
const toolbar = el("div", undefined, "cache-rules-toolbar");
|
||||||
if (scope === "vhost") { const docs = el("a", t("cacheRulesDocs"), "docs-link"); docs.href = "/docs#doc=docs%2FCACHE.md§ion=cache-rules-vcl-style"; docs.target = "_blank"; docs.rel = "noopener noreferrer"; root.append(docs); }
|
if (scope === "vhost") {
|
||||||
|
// Both ordinary vhost and Docker assignment editors use this component.
|
||||||
|
// The shared guide opener is delegated in settings.js, so dynamic editors
|
||||||
|
// receive the same modal without binding additional event handlers.
|
||||||
|
const helpLinks = el("div", undefined, "cache-rules-vhost-links");
|
||||||
|
const docs = el("a", t("cacheRulesDocs"), "docs-link");
|
||||||
|
docs.href = "/docs#doc=docs%2FCACHE.md§ion=cache-rules-vcl-style";
|
||||||
|
docs.target = "_blank";
|
||||||
|
docs.rel = "noopener noreferrer";
|
||||||
|
const guide = el("button", t("cacheGuideOpen"), "outline cache-guide-trigger");
|
||||||
|
guide.type = "button";
|
||||||
|
helpLinks.append(guide, docs);
|
||||||
|
root.append(helpLinks);
|
||||||
|
}
|
||||||
const templates = select([["", t("cacheRulesTemplates")], ...Object.keys(TEMPLATES).map(key => [key, t(`cacheRuleTpl${key[0].toUpperCase()}${key.slice(1)}`)])], "", t("cacheRulesTemplates"));
|
const templates = select([["", t("cacheRulesTemplates")], ...Object.keys(TEMPLATES).map(key => [key, t(`cacheRuleTpl${key[0].toUpperCase()}${key.slice(1)}`)])], "", t("cacheRulesTemplates"));
|
||||||
templates.classList.add("cache-rules-templates");
|
templates.classList.add("cache-rules-templates");
|
||||||
const importButton = el("button", t("cacheRulesImportVcl"), "outline"); importButton.type = "button";
|
const importButton = el("button", t("cacheRulesImportVcl"), "outline"); importButton.type = "button";
|
||||||
@@ -236,9 +276,21 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const importBox = el("div", undefined, "cache-rules-import"); importBox.hidden = true;
|
const importBox = el("div", undefined, "cache-rules-import"); importBox.hidden = true;
|
||||||
const importText = document.createElement("textarea"); importText.rows = 10; importText.spellcheck = false; importText.placeholder = "sub vcl_recv {\n if (req.url ~ \"^/admin\") {\n return (pass);\n }\n}";
|
const importText = document.createElement("textarea"); importText.rows = 10; importText.spellcheck = false; importText.placeholder = "sub vcl_recv {\n if (req.url ~ \"^/admin\") {\n return (pass);\n }\n}";
|
||||||
const importRun = el("button", t("cacheRulesImportRun"), "primary"); importRun.type = "button";
|
const importRun = el("button", t("cacheRulesImportRun"), "primary"); importRun.type = "button";
|
||||||
|
const importApply = el("button", t("cacheRulesImportApplyPartial"), "outline"); importApply.type = "button"; importApply.hidden = true;
|
||||||
const importCancel = el("button", t("cancel"), "outline"); importCancel.type = "button";
|
const importCancel = el("button", t("cancel"), "outline"); importCancel.type = "button";
|
||||||
const importResult = el("div", undefined, "cache-rules-import-result");
|
const importResult = el("div", undefined, "cache-rules-import-result");
|
||||||
const importActions = el("div", undefined, "form-actions"); importActions.append(importRun, importCancel);
|
const importActions = el("div", undefined, "form-actions"); importActions.append(importRun, importApply, importCancel);
|
||||||
|
let pendingImport = null, importGeneration = 0;
|
||||||
|
// Any edit/close/submit supersedes older in-flight API responses. An old
|
||||||
|
// parse result must never mutate the editor after the user cancelled it.
|
||||||
|
const resetImportPreview = () => {
|
||||||
|
importGeneration++;
|
||||||
|
pendingImport = null;
|
||||||
|
importApply.hidden = true;
|
||||||
|
importResult.replaceChildren();
|
||||||
|
importRun.disabled = false;
|
||||||
|
};
|
||||||
|
importText.addEventListener("input", resetImportPreview);
|
||||||
importBox.append(el("p", t("cacheRulesImportHelp"), "fine"), importText, importActions, importResult);
|
importBox.append(el("p", t("cacheRulesImportHelp"), "fine"), importText, importActions, importResult);
|
||||||
const exportBox = el("details", undefined, "cache-rules-export"); const exportSummary = el("summary", t("cacheRulesVclPreview")); const exportPre = el("pre", "", "metrics-example mono cache-rules-vcl");
|
const exportBox = el("details", undefined, "cache-rules-export"); const exportSummary = el("summary", t("cacheRulesVclPreview")); const exportPre = el("pre", "", "metrics-example mono cache-rules-vcl");
|
||||||
exportBox.append(exportSummary, exportPre);
|
exportBox.append(exportSummary, exportPre);
|
||||||
@@ -312,7 +364,7 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const id = textInput(rule.id, "", "mono"); id.maxLength = 64; id.pattern = "[A-Za-z0-9_\\-]{1,64}";
|
const id = textInput(rule.id, "", "mono"); id.maxLength = 64; id.pattern = "[A-Za-z0-9_\\-]{1,64}";
|
||||||
id.addEventListener("change", () => { const value = id.value.trim(); if (!/^[A-Za-z0-9_-]{1,64}$/.test(value) || (value !== rule.id && taken().has(value))) { id.value = rule.id; toast(t("cacheRuleIdInvalid"), true); return; } open.delete(rule.id); rule.id = value; open.add(value); changed(); });
|
id.addEventListener("change", () => { const value = id.value.trim(); if (!/^[A-Za-z0-9_-]{1,64}$/.test(value) || (value !== rule.id && taken().has(value))) { id.value = rule.id; toast(t("cacheRuleIdInvalid"), true); return; } open.delete(rule.id); rule.id = value; open.add(value); changed(); });
|
||||||
const stage = select(STAGES.map(value => [value, t(STAGE_KEYS[value])]), rule.stage, t("cacheRuleStage"));
|
const stage = select(STAGES.map(value => [value, t(STAGE_KEYS[value])]), rule.stage, t("cacheRuleStage"));
|
||||||
stage.addEventListener("change", () => { rule.stage = stage.value; rule.actions = rule.actions.filter(a => ACTIONS[rule.stage].includes(a.type)); if (!rule.actions.length) rule.actions = [{ type: ACTIONS[rule.stage][0] }]; rule.conditions = rule.conditions.filter(c => FIELDS[c.field].stages.includes(rule.stage)); render(); changed(); });
|
stage.addEventListener("change", () => { rule.stage = stage.value; if (rule.stage !== "request") rule.hash_stage = false; rule.actions = rule.actions.filter(a => ACTIONS[rule.stage].includes(a.type)); if (!rule.actions.length && !rule.stop) rule.actions = [{ type: ACTIONS[rule.stage][0] }]; rule.conditions = rule.conditions.filter(c => FIELDS[c.field].stages.includes(rule.stage)); render(); changed(); });
|
||||||
const match = select([["all", t("cacheRuleMatchAll")], ["any", t("cacheRuleMatchAny")]], rule.match, t("cacheRuleMatch"));
|
const match = select([["all", t("cacheRuleMatchAll")], ["any", t("cacheRuleMatchAny")]], rule.match, t("cacheRuleMatch"));
|
||||||
match.addEventListener("change", () => { rule.match = match.value; changed(); syncPreview(); });
|
match.addEventListener("change", () => { rule.match = match.value; changed(); syncPreview(); });
|
||||||
const stop = el("input", undefined, "switch"); stop.type = "checkbox"; stop.checked = rule.stop; stop.addEventListener("change", () => { rule.stop = stop.checked; changed(); });
|
const stop = el("input", undefined, "switch"); stop.type = "checkbox"; stop.checked = rule.stop; stop.addEventListener("change", () => { rule.stop = stop.checked; changed(); });
|
||||||
@@ -378,7 +430,7 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const row = el("div", undefined, "cache-rule-row");
|
const row = el("div", undefined, "cache-rule-row");
|
||||||
const type = select(ACTIONS[rule.stage].map(value => [value, actionLabel(value)]), action.type, t("cacheRuleAction"));
|
const type = select(ACTIONS[rule.stage].map(value => [value, actionLabel(value)]), action.type, t("cacheRuleAction"));
|
||||||
const params = el("span", undefined, "cache-rule-params");
|
const params = el("span", undefined, "cache-rule-params");
|
||||||
const remove = el("button", "×", "quiet"); remove.type = "button"; remove.setAttribute("aria-label", t("remove")); remove.disabled = rule.actions.length <= 1;
|
const remove = el("button", "×", "quiet"); remove.type = "button"; remove.setAttribute("aria-label", t("remove")); remove.disabled = rule.actions.length <= 1 && !rule.stop;
|
||||||
type.addEventListener("change", () => { rule.actions[index] = { type: type.value }; render(); changed(); });
|
type.addEventListener("change", () => { rule.actions[index] = { type: type.value }; render(); changed(); });
|
||||||
remove.addEventListener("click", () => { rule.actions.splice(index, 1); render(); changed(); });
|
remove.addEventListener("click", () => { rule.actions.splice(index, 1); render(); changed(); });
|
||||||
const listInput = (key, placeholder) => { const node = textInput((action[key] || []).join(", "), placeholder); node.addEventListener("input", () => { action[key] = splitList(node.value); changed(); }); return node; };
|
const listInput = (key, placeholder) => { const node = textInput((action[key] || []).join(", "), placeholder); node.addEventListener("input", () => { action[key] = splitList(node.value); changed(); }); return node; };
|
||||||
@@ -393,6 +445,8 @@ window.rustProxyCacheRules = (() => {
|
|||||||
case "hash_header": params.append(nameInput("Accept-Language")); break;
|
case "hash_header": params.append(nameInput("Accept-Language")); break;
|
||||||
case "hash_cookie": params.append(nameInput("lang")); break;
|
case "hash_cookie": params.append(nameInput("lang")); break;
|
||||||
case "ttl": case "grace": params.append(durationInput(action.seconds ?? (action.type === "ttl" ? 3600 : 60), seconds => { action.seconds = seconds; changed(); })); if (action.seconds == null) action.seconds = action.type === "ttl" ? 3600 : 60; break;
|
case "ttl": case "grace": params.append(durationInput(action.seconds ?? (action.type === "ttl" ? 3600 : 60), seconds => { action.seconds = seconds; changed(); })); if (action.seconds == null) action.seconds = action.type === "ttl" ? 3600 : 60; break;
|
||||||
|
case "set_backend_header": case "set_request_header": { const value = textInput(action.value, t("cacheRuleHeaderValue")); value.addEventListener("input", () => { action.value = value.value; changed(); }); params.append(nameInput(action.type === "set_request_header" ? "X-Device" : "Cache-Control"), value); break; }
|
||||||
|
case "remove_backend_header": case "remove_request_header": params.append(nameInput(action.type === "remove_request_header" ? "X-Tracking" : "Cache-Control")); break;
|
||||||
case "set_header": { const value = textInput(action.value, t("cacheRuleHeaderValue")); value.addEventListener("input", () => { action.value = value.value; changed(); }); params.append(nameInput("X-Cache-Rule"), value); break; }
|
case "set_header": { const value = textInput(action.value, t("cacheRuleHeaderValue")); value.addEventListener("input", () => { action.value = value.value; changed(); }); params.append(nameInput("X-Cache-Rule"), value); break; }
|
||||||
case "default_header": { const value = textInput(action.value, t("cacheRuleHeaderValue")); value.addEventListener("input", () => { action.value = value.value; changed(); }); params.append(nameInput("Cache-Control"), value); break; }
|
case "default_header": { const value = textInput(action.value, t("cacheRuleHeaderValue")); value.addEventListener("input", () => { action.value = value.value; changed(); }); params.append(nameInput("Cache-Control"), value); break; }
|
||||||
case "remove_header": params.append(nameInput("X-Powered-By")); break;
|
case "remove_header": params.append(nameInput("X-Powered-By")); break;
|
||||||
@@ -404,33 +458,53 @@ window.rustProxyCacheRules = (() => {
|
|||||||
function buildTester() {
|
function buildTester() {
|
||||||
const node = el("details", undefined, "cache-rules-tester");
|
const node = el("details", undefined, "cache-rules-tester");
|
||||||
node.append(el("summary", t("cacheRulesTester")));
|
node.append(el("summary", t("cacheRulesTester")));
|
||||||
const grid = el("div", undefined, "cache-rules-tester-grid");
|
const bodyWrap = el("div", undefined, "cache-rules-tester-body");
|
||||||
|
const sections = el("div", undefined, "cache-rules-tester-sections");
|
||||||
|
const requestPane = el("section", undefined, "cache-rules-tester-pane");
|
||||||
|
requestPane.append(el("h4", t("cacheRulesTesterRequestTitle"), "cache-rules-tester-heading"));
|
||||||
|
const requestGrid = el("div", undefined, "cache-rules-tester-grid cache-rules-tester-request-grid");
|
||||||
const method = select(["GET", "HEAD", "POST"].map(value => [value, value]), "GET", t("cacheRuleFieldMethod"));
|
const method = select(["GET", "HEAD", "POST"].map(value => [value, value]), "GET", t("cacheRuleFieldMethod"));
|
||||||
const url = textInput("", scope === "vhost" ? "/produkt?id=7&utm_source=fb" : "https://shop.example.com/produkt?id=7&utm_source=fb", "mono");
|
const url = textInput("", scope === "vhost" ? "/produkt?id=7&utm_source=fb" : "https://shop.example.com/produkt?id=7&utm_source=fb", "mono");
|
||||||
const vhostSelect = select([["", t("cacheRulesTesterNoVhost")], ...targetList().map(target => [target.id, targetTitle(target)])], vhostId, t("cacheRulesTesterVhost"));
|
const vhostSelect = select([["", t("cacheRulesTesterNoVhost")], ...targetList().map(target => [target.id, targetTitle(target)])], vhostId, t("cacheRulesTesterVhost"));
|
||||||
if (scope === "global") document.addEventListener("rustproxy-cache-targets", () => {
|
if (scope === "global") document.addEventListener("rustproxy-cache-targets", () => {
|
||||||
|
if (!root.isConnected) return;
|
||||||
const current = vhostSelect.value;
|
const current = vhostSelect.value;
|
||||||
vhostSelect.replaceChildren(...[["", t("cacheRulesTesterNoVhost")], ...targetList().map(target => [target.id, targetTitle(target)])].map(([value, text]) => { const option = el("option", text); option.value = value; return option; }));
|
vhostSelect.replaceChildren(...[["", t("cacheRulesTesterNoVhost")], ...targetList().map(target => [target.id, targetTitle(target)])].map(([value, text]) => { const option = el("option", text); option.value = value; return option; }));
|
||||||
vhostSelect.value = [...vhostSelect.options].some(option => option.value === current) ? current : "";
|
vhostSelect.value = [...vhostSelect.options].some(option => option.value === current) ? current : "";
|
||||||
});
|
});
|
||||||
const headers = document.createElement("textarea"); headers.rows = 3; headers.placeholder = "Cookie: lang=pl; sid=1\nAccept-Language: pl"; headers.spellcheck = false;
|
const headers = document.createElement("textarea"); headers.rows = 2; headers.placeholder = "Cookie: lang=pl; sid=1\nAccept-Language: pl"; headers.spellcheck = false;
|
||||||
const clientIp = textInput("", "203.0.113.10", "mono");
|
const clientIp = textInput("", "203.0.113.10", "mono");
|
||||||
const status = el("input"); status.type = "number"; status.min = 100; status.max = 599; status.value = 200;
|
const status = el("input"); status.type = "number"; status.min = 100; status.max = 599; status.value = 200;
|
||||||
const responseHeaders = document.createElement("textarea"); responseHeaders.rows = 3; responseHeaders.placeholder = "Cache-Control: public, max-age=60\nContent-Type: text/html"; responseHeaders.spellcheck = false;
|
const responseHeaders = document.createElement("textarea"); responseHeaders.rows = 2; responseHeaders.placeholder = "Cache-Control: public, max-age=60\nContent-Type: text/html"; responseHeaders.spellcheck = false;
|
||||||
const run = el("button", t("cacheRulesTesterRun"), "primary"); run.type = "button";
|
const run = el("button", t("cacheRulesTesterRun"), "primary"); run.type = "button";
|
||||||
const result = el("div", undefined, "cache-rules-tester-result");
|
const result = el("div", undefined, "cache-rules-tester-result"); result.setAttribute("aria-live", "polite");
|
||||||
const field = (key, control) => { const label = el("label", undefined, "cache-rule-field"); label.append(el("span", t(key)), control); return label; };
|
const field = (key, control, cls) => { const label = el("label", undefined, `cache-rule-field ${cls}`); label.append(el("span", t(key)), control); return label; };
|
||||||
grid.append(field("cacheRuleFieldMethod", method), field("cacheRulesTesterUrl", url));
|
requestGrid.append(field("cacheRuleFieldMethod", method, "is-method"), field("cacheRulesTesterUrl", url, "is-url"));
|
||||||
if (scope === "global") grid.append(field("cacheRulesTesterVhost", vhostSelect));
|
if (scope === "global") requestGrid.append(field("cacheRulesTesterVhost", vhostSelect, "is-vhost"));
|
||||||
grid.append(field("cacheRulesTesterHeaders", headers), field("cacheRuleFieldClientIp", clientIp), field("cacheRuleFieldStatus", status), field("cacheRulesTesterResponseHeaders", responseHeaders));
|
requestGrid.append(field("cacheRuleFieldClientIp", clientIp, "is-ip"), field("cacheRulesTesterHeaders", headers, "is-headers"));
|
||||||
|
requestPane.append(requestGrid);
|
||||||
|
const responsePane = el("section", undefined, "cache-rules-tester-pane");
|
||||||
|
responsePane.append(el("h4", t("cacheRulesTesterResponseTitle"), "cache-rules-tester-heading"));
|
||||||
|
const responseGrid = el("div", undefined, "cache-rules-tester-grid cache-rules-tester-response-grid");
|
||||||
|
responseGrid.append(field("cacheRuleFieldStatus", status, "is-status"), field("cacheRulesTesterResponseHeaders", responseHeaders, "is-response-headers"));
|
||||||
|
responsePane.append(responseGrid);
|
||||||
|
sections.append(requestPane, responsePane);
|
||||||
const pairs = text => String(text || "").split(/\r?\n/).map(line => line.trim()).filter(Boolean).map(line => { const at = line.indexOf(":"); return at > 0 ? [line.slice(0, at).trim(), line.slice(at + 1).trim()] : [line, ""]; });
|
const pairs = text => String(text || "").split(/\r?\n/).map(line => line.trim()).filter(Boolean).map(line => { const at = line.indexOf(":"); return at > 0 ? [line.slice(0, at).trim(), line.slice(at + 1).trim()] : [line, ""]; });
|
||||||
run.addEventListener("click", async () => {
|
run.addEventListener("click", async () => {
|
||||||
run.disabled = true; result.replaceChildren(el("p", t("cacheRulesTesterRunning"), "fine"));
|
run.disabled = true; result.replaceChildren(el("p", t("cacheRulesTesterRunning"), "fine"));
|
||||||
try {
|
try {
|
||||||
const body = { request: { method: method.value, url: url.value.trim(), headers: pairs(headers.value), client_ip: clientIp.value.trim() || null }, response: { status: Number(status.value) || 200, headers: pairs(responseHeaders.value) } };
|
const requestHeaders = pairs(headers.value);
|
||||||
if (scope === "global") { body.global_rules = read(); body.vhost_id = vhostSelect.value || null; }
|
// A draft/new vhost has no stored frontend.hosts entry yet. With a
|
||||||
else { body.vhost_id = vhostId || null; body.vhost_rules = read(); body.ignore_global_rules = ignoreGlobal; if (!vhostId) body.vhost_id = null; }
|
// path-only test use its current editor hostname, not an empty Host,
|
||||||
renderResult(await api("/api/cache/rules/test", { method: "POST", body: JSON.stringify(body) }));
|
// so global host conditions are evaluated consistently.
|
||||||
|
if (scope === "vhost" && url.value.trim().startsWith("/") && !requestHeaders.some(([name]) => name.toLowerCase() === "host")) {
|
||||||
|
const host = String(typeof options.testHost === "function" ? options.testHost() || "" : "").trim();
|
||||||
|
if (host && !host.startsWith("*.")) requestHeaders.push(["Host", host]);
|
||||||
|
}
|
||||||
|
const payload = { request: { method: method.value, url: url.value.trim(), headers: requestHeaders, client_ip: clientIp.value.trim() || null }, response: { status: Number(status.value) || 200, headers: pairs(responseHeaders.value) } };
|
||||||
|
if (scope === "global") { payload.global_rules = read(); payload.vhost_id = vhostSelect.value || null; }
|
||||||
|
else { payload.vhost_id = vhostId || null; payload.vhost_rules = read(); payload.ignore_global_rules = ignoreGlobal; }
|
||||||
|
renderResult(await api("/api/cache/rules/test", { method: "POST", body: JSON.stringify(payload) }));
|
||||||
} catch (error) { result.replaceChildren(el("p", error.message, "fine is-error")); }
|
} catch (error) { result.replaceChildren(el("p", error.message, "fine is-error")); }
|
||||||
finally { run.disabled = false; }
|
finally { run.disabled = false; }
|
||||||
});
|
});
|
||||||
@@ -441,6 +515,7 @@ window.rustProxyCacheRules = (() => {
|
|||||||
const request = data.request || {};
|
const request = data.request || {};
|
||||||
line(t("cacheRulesResultDecision"), request.cacheable ? (data.response?.stored ? t("cacheRulesResultHit").replace("{ttl}", fmtDuration(data.response.ttl)).replace("{grace}", fmtDuration(data.response.grace)) : t("cacheRulesResultNotStored").replace("{reason}", data.response?.reason || "-")) : t("cacheRulesResultPass").replace("{reason}", request.reason || "-"), request.cacheable && data.response?.stored ? "is-ok" : "is-warn");
|
line(t("cacheRulesResultDecision"), request.cacheable ? (data.response?.stored ? t("cacheRulesResultHit").replace("{ttl}", fmtDuration(data.response.ttl)).replace("{grace}", fmtDuration(data.response.grace)) : t("cacheRulesResultNotStored").replace("{reason}", data.response?.reason || "-")) : t("cacheRulesResultPass").replace("{reason}", request.reason || "-"), request.cacheable && data.response?.stored ? "is-ok" : "is-warn");
|
||||||
line(t("cacheRulesResultRequest"), names(request.matched));
|
line(t("cacheRulesResultRequest"), names(request.matched));
|
||||||
|
if (request.header_edits?.length) line(t("cacheRulesResultRequestHeaders"), request.header_edits.map(edit => edit.type === "set" ? `${edit.name}: ${edit.value}` : `−${edit.name}`).join(", "));
|
||||||
line(t("cacheRulesResultKey"), `${data.host || "-"}${request.target || ""}${request.variant?.length ? ` + ${request.variant.join(", ")}` : ""}`);
|
line(t("cacheRulesResultKey"), `${data.host || "-"}${request.target || ""}${request.variant?.length ? ` + ${request.variant.join(", ")}` : ""}`);
|
||||||
if (request.cookie != null) line(t("cacheRulesResultCookie"), request.cookie || "—");
|
if (request.cookie != null) line(t("cacheRulesResultCookie"), request.cookie || "—");
|
||||||
if (data.response) line(t("cacheRulesResultResponse"), names(data.response.matched));
|
if (data.response) line(t("cacheRulesResultResponse"), names(data.response.matched));
|
||||||
@@ -448,8 +523,10 @@ window.rustProxyCacheRules = (() => {
|
|||||||
for (const item of [...(request.overridden || []), ...(data.response?.overridden || [])]) line(t("cacheRulesResultOverridden"), t("cacheRulesResultOverriddenText").replace("{winner}", item.winner).replace("{ignored}", item.ignored).replace("{aspect}", t(`cacheRuleAspect${item.aspect[0].toUpperCase()}${item.aspect.slice(1)}`)), "is-warn");
|
for (const item of [...(request.overridden || []), ...(data.response?.overridden || [])]) line(t("cacheRulesResultOverridden"), t("cacheRulesResultOverriddenText").replace("{winner}", item.winner).replace("{ignored}", item.ignored).replace("{aspect}", t(`cacheRuleAspect${item.aspect[0].toUpperCase()}${item.aspect.slice(1)}`)), "is-warn");
|
||||||
result.replaceChildren(...items);
|
result.replaceChildren(...items);
|
||||||
}
|
}
|
||||||
const actions = el("div", undefined, "form-actions"); actions.append(run);
|
const footer = el("div", undefined, "cache-rules-tester-footer");
|
||||||
node.append(el("p", t("cacheRulesTesterHelp"), "fine"), grid, actions, result);
|
footer.append(el("p", t(scope === "global" ? "cacheRulesTesterHelpGlobal" : "cacheRulesTesterHelpVhost"), "fine"), run);
|
||||||
|
bodyWrap.append(sections, footer, result);
|
||||||
|
node.append(bodyWrap);
|
||||||
return { node };
|
return { node };
|
||||||
}
|
}
|
||||||
function addRules(items) {
|
function addRules(items) {
|
||||||
@@ -464,28 +541,56 @@ window.rustProxyCacheRules = (() => {
|
|||||||
}
|
}
|
||||||
templates.addEventListener("change", () => { const make = TEMPLATES[templates.value]; templates.value = ""; if (!make) return; const added = addRules(make()); if (added) toast(t("cacheRulesTemplateAdded").replace("{count}", added)); });
|
templates.addEventListener("change", () => { const make = TEMPLATES[templates.value]; templates.value = ""; if (!make) return; const added = addRules(make()); if (added) toast(t("cacheRulesTemplateAdded").replace("{count}", added)); });
|
||||||
addButton.addEventListener("click", () => { const rule = blankRule(taken()); rules.push(rule); open.add(rule.id); render(); changed(); list.lastElementChild?.scrollIntoView?.({ block: "nearest", behavior: "smooth" }); });
|
addButton.addEventListener("click", () => { const rule = blankRule(taken()); rules.push(rule); open.add(rule.id); render(); changed(); list.lastElementChild?.scrollIntoView?.({ block: "nearest", behavior: "smooth" }); });
|
||||||
importButton.addEventListener("click", () => { importBox.hidden = !importBox.hidden; if (!importBox.hidden) importText.focus(); });
|
importButton.addEventListener("click", () => { importBox.hidden = !importBox.hidden; if (importBox.hidden) resetImportPreview(); else importText.focus(); });
|
||||||
importCancel.addEventListener("click", () => { importBox.hidden = true; importResult.replaceChildren(); });
|
importCancel.addEventListener("click", () => { importBox.hidden = true; resetImportPreview(); });
|
||||||
importRun.addEventListener("click", async () => {
|
importRun.addEventListener("click", async () => {
|
||||||
importRun.disabled = true; importResult.replaceChildren();
|
resetImportPreview();
|
||||||
|
const generation = importGeneration;
|
||||||
|
importRun.disabled = true;
|
||||||
|
const source = importText.value;
|
||||||
try {
|
try {
|
||||||
const data = await api("/api/cache/rules/import-vcl", { method: "POST", body: JSON.stringify({ vcl: importText.value }) });
|
const data = await api("/api/cache/rules/import-vcl", { method: "POST", body: JSON.stringify({ vcl: source }) });
|
||||||
|
// The user must opt into a partial/approximated import after seeing
|
||||||
|
// warnings. Previously incomplete VCL was added before any warning was shown.
|
||||||
|
if (generation !== importGeneration || importText.value !== source || importBox.hidden) return;
|
||||||
|
if (data.warnings?.length) {
|
||||||
|
const list = el("ul", undefined, "cache-rules-warnings");
|
||||||
|
for (const warning of data.warnings) list.append(el("li", warning));
|
||||||
|
importResult.append(el("p", t("cacheRulesImportWarnings"), "fine is-warn"), list);
|
||||||
|
if (data.rules?.length) {
|
||||||
|
pendingImport = data.rules;
|
||||||
|
importApply.hidden = false;
|
||||||
|
importResult.append(el("p", t("cacheRulesImportPending").replace("{count}", data.rules.length), "fine"));
|
||||||
|
} else {
|
||||||
|
importResult.append(el("p", t("cacheRulesImportNoActions"), "fine"));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
const added = addRules(data.rules || []);
|
const added = addRules(data.rules || []);
|
||||||
|
importResult.append(el("p", added ? t("cacheRulesImportDone").replace("{count}", added) : t("cacheRulesImportNoActions"), "fine is-ok"));
|
||||||
|
} catch (error) {
|
||||||
|
if (generation === importGeneration && !importBox.hidden)
|
||||||
|
importResult.append(el("p", error.message, "fine is-error"));
|
||||||
|
} finally {
|
||||||
|
if (generation === importGeneration) importRun.disabled = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
importApply.addEventListener("click", () => {
|
||||||
|
if (!pendingImport) return;
|
||||||
|
const added = addRules(pendingImport);
|
||||||
|
resetImportPreview();
|
||||||
importResult.append(el("p", t("cacheRulesImportDone").replace("{count}", added), "fine is-ok"));
|
importResult.append(el("p", t("cacheRulesImportDone").replace("{count}", added), "fine is-ok"));
|
||||||
if (data.warnings?.length) { const list = el("ul", undefined, "cache-rules-warnings"); for (const warning of data.warnings) list.append(el("li", warning)); importResult.append(el("p", t("cacheRulesImportWarnings"), "fine"), list); }
|
|
||||||
} catch (error) { importResult.append(el("p", error.message, "fine is-error")); }
|
|
||||||
finally { importRun.disabled = false; }
|
|
||||||
});
|
});
|
||||||
exportButton.addEventListener("click", async () => { exportBox.open = true; exportBox.scrollIntoView?.({ block: "nearest", behavior: "smooth" }); try { await navigator.clipboard.writeText(exportPre.textContent); toast(t("copied")); } catch { } });
|
exportButton.addEventListener("click", async () => { exportBox.open = true; exportBox.scrollIntoView?.({ block: "nearest", behavior: "smooth" }); try { await navigator.clipboard.writeText(exportPre.textContent); toast(t("copied")); } catch { } });
|
||||||
ignoreBox.addEventListener("change", () => { ignoreGlobal = ignoreBox.checked; renderNotices(); changed(); });
|
ignoreBox.addEventListener("change", () => { ignoreGlobal = ignoreBox.checked; renderNotices(); changed(); });
|
||||||
function read() {
|
function read() {
|
||||||
for (const rule of rules) {
|
for (const rule of rules) {
|
||||||
if (!rule.actions.length) throw new Error(t("cacheRuleNeedsAction").replace("{rule}", rule.name || rule.id));
|
if (!rule.actions.length && !rule.stop) throw new Error(t("cacheRuleNeedsAction").replace("{rule}", rule.name || rule.id));
|
||||||
for (const c of rule.conditions) {
|
for (const c of rule.conditions) {
|
||||||
if (FIELDS[c.field].name && !c.name) throw new Error(t("cacheRuleNeedsName").replace("{rule}", rule.name || rule.id));
|
if (FIELDS[c.field].name && !c.name) throw new Error(t("cacheRuleNeedsName").replace("{rule}", rule.name || rule.id));
|
||||||
if (c.operator !== "exists" && !(c.values || []).length) throw new Error(t("cacheRuleNeedsValue").replace("{rule}", rule.name || rule.id));
|
if (c.operator !== "exists" && !(c.values || []).length) throw new Error(t("cacheRuleNeedsValue").replace("{rule}", rule.name || rule.id));
|
||||||
}
|
}
|
||||||
for (const a of rule.actions) if (["hash_header", "hash_cookie", "set_header", "default_header", "remove_header"].includes(a.type) && !a.name) throw new Error(t("cacheRuleNeedsName").replace("{rule}", rule.name || rule.id));
|
for (const a of rule.actions) if (["hash_header", "hash_cookie", "set_request_header", "remove_request_header", "set_backend_header", "remove_backend_header", "set_header", "default_header", "remove_header"].includes(a.type) && !a.name) throw new Error(t("cacheRuleNeedsName").replace("{rule}", rule.name || rule.id));
|
||||||
}
|
}
|
||||||
return rules.map(rule => clean(rule, scope === "global"));
|
return rules.map(rule => clean(rule, scope === "global"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,18 +102,18 @@
|
|||||||
rows as a subgrid, so a caption that wraps to more lines makes the whole
|
rows as a subgrid, so a caption that wraps to more lines makes the whole
|
||||||
caption row taller and every control in the row still starts on the same
|
caption row taller and every control in the row still starts on the same
|
||||||
line. Multi-line text areas take the whole row instead of a narrow column. */
|
line. Multi-line text areas take the whole row instead of a narrow column. */
|
||||||
:is(.vh-grid>.vh-field, .cache-rules-tester-grid>.cache-rule-field, .field-grid>label:not([class])) {
|
:is(.vh-grid>.vh-field, .field-grid>label:not([class])) {
|
||||||
grid-row: span 2;
|
grid-row: span 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
:is(.vh-grid>.vh-field, .cache-rules-tester-grid>.cache-rule-field, .field-grid>label:not([class])):has(>:nth-child(2):last-child) {
|
:is(.vh-grid>.vh-field, .field-grid>label:not([class])):has(>:nth-child(2):last-child) {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-rows: subgrid;
|
grid-template-rows: subgrid;
|
||||||
row-gap: 4px;
|
row-gap: 4px;
|
||||||
align-content: start;
|
align-content: start;
|
||||||
}
|
}
|
||||||
|
|
||||||
:is(.vh-grid>.vh-field, .cache-rules-tester-grid>.cache-rule-field, .field-grid>label:not([class])):has(>:nth-child(2):last-child)>:first-child {
|
:is(.vh-grid>.vh-field, .field-grid>label:not([class])):has(>:nth-child(2):last-child)>:first-child {
|
||||||
align-self: end;
|
align-self: end;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2700,35 +2700,184 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Shared compact rule tester (global Cache, Vhosts and Docker vhosts).
|
||||||
|
Keep controls aligned without the vhost editor's two-row subgrid. */
|
||||||
|
.cache-rules-vhost-links {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 6px 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-vhost-links>.cache-guide-trigger {
|
||||||
|
width: auto;
|
||||||
|
min-height: 30px;
|
||||||
|
padding: 5px 10px;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
.cache-rules-tester {
|
.cache-rules-tester {
|
||||||
padding: 10px 12px;
|
width: 100%;
|
||||||
|
max-width: 1120px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 0;
|
||||||
border: 1px solid var(--line);
|
border: 1px solid var(--line);
|
||||||
border-radius: var(--rp-radius-surface, 0px);
|
border-radius: var(--rp-radius-surface, 0px);
|
||||||
|
container-type: inline-size;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester>summary {
|
||||||
|
padding: 9px 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester[open]>summary {
|
||||||
|
border-bottom: 1px solid var(--line);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-body {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 11px 12px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-sections {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(min(100%, 390px), 1fr));
|
||||||
|
gap: 10px;
|
||||||
|
align-items: stretch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-pane {
|
||||||
|
min-width: 0;
|
||||||
|
padding: 10px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
border-radius: var(--rp-radius-surface, 0px);
|
||||||
|
background: var(--panel2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-heading {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
font-size: 11px;
|
||||||
|
letter-spacing: .05em;
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: var(--muted);
|
||||||
}
|
}
|
||||||
|
|
||||||
.cache-rules-tester-grid {
|
.cache-rules-tester-grid {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
|
grid-template-columns: minmax(100px, .65fr) repeat(2, minmax(0, 1fr));
|
||||||
gap: 10px 14px;
|
gap: 8px 10px;
|
||||||
margin-top: 8px;
|
margin: 0;
|
||||||
|
align-items: start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-grid>.cache-rule-field {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
grid-row: auto;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-grid>.cache-rule-field>span {
|
||||||
|
display: block;
|
||||||
|
color: var(--muted);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.25;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-grid :is(input, select, textarea) {
|
||||||
|
display: block;
|
||||||
|
width: 100%;
|
||||||
|
min-width: 0;
|
||||||
|
max-width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 6px 8px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-grid :is(input, select) {
|
||||||
|
height: 34px;
|
||||||
|
min-height: 34px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cache-rules-tester-grid textarea {
|
.cache-rules-tester-grid textarea {
|
||||||
|
min-height: 52px;
|
||||||
font-family: var(--mono);
|
font-family: var(--mono);
|
||||||
font-size: 12px;
|
line-height: 1.35;
|
||||||
|
resize: vertical;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-request-grid>.is-url,
|
||||||
|
.cache-rules-tester-request-grid>.is-vhost {
|
||||||
|
grid-column: span 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-request-grid>.is-headers {
|
||||||
|
grid-column: 1 / -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-response-grid {
|
||||||
|
grid-template-columns: 110px minmax(0, 1fr);
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-footer {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-footer>.fine {
|
||||||
|
flex: 1 1 370px;
|
||||||
|
min-width: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.4;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-footer>button {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
width: auto;
|
||||||
|
min-height: 32px;
|
||||||
|
padding: 6px 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.cache-rules-tester-result {
|
.cache-rules-tester-result {
|
||||||
display: grid;
|
display: grid;
|
||||||
gap: 4px;
|
gap: 4px;
|
||||||
margin-top: 8px;
|
min-width: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.cache-rules-tester-result:empty { display: none; }
|
||||||
|
|
||||||
.cache-rules-result-line {
|
.cache-rules-result-line {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: minmax(140px, 200px) minmax(0, 1fr);
|
grid-template-columns: minmax(120px, 190px) minmax(0, 1fr);
|
||||||
gap: 10px;
|
gap: 8px 10px;
|
||||||
|
padding: 6px 9px;
|
||||||
|
border: 1px solid var(--line);
|
||||||
overflow-wrap: anywhere;
|
overflow-wrap: anywhere;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cache-rules-result-line>strong { min-width: 0; }
|
||||||
|
|
||||||
|
@container (max-width: 550px) {
|
||||||
|
.cache-rules-tester-body { padding: 9px; }
|
||||||
|
.cache-rules-tester-pane { padding: 9px; }
|
||||||
|
.cache-rules-tester-request-grid { grid-template-columns: minmax(105px, 1fr) minmax(0, 1fr); }
|
||||||
|
.cache-rules-tester-request-grid>.is-url,
|
||||||
|
.cache-rules-tester-request-grid>.is-vhost { grid-column: 1 / -1; }
|
||||||
|
.cache-rules-tester-request-grid>.is-ip { grid-column: span 1; }
|
||||||
|
.cache-rules-tester-response-grid { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
.cache-rules-tester-response-grid>.is-status { max-width: 170px; }
|
||||||
|
.cache-rules-tester-response-grid>.is-response-headers { grid-column: 1 / -1; }
|
||||||
|
.cache-rules-result-line { grid-template-columns: minmax(0, 1fr); gap: 3px; }
|
||||||
}
|
}
|
||||||
|
|
||||||
.cache-rules-result-line.is-ok>strong {
|
.cache-rules-result-line.is-ok>strong {
|
||||||
@@ -3404,3 +3553,71 @@ html[data-dashboard-density=normal] #panel-overview .stat>span,
|
|||||||
grid-template-columns: 1fr;
|
grid-template-columns: 1fr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Contextual cache / VCL help in Settings -> Cache. */
|
||||||
|
.cache-guide-heading-actions {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
#cache-form .cache-guide-trigger { width: auto; }
|
||||||
|
#cache-form [data-cache-settings-page=rules]>.cache-guide-trigger { margin-left: 10px; }
|
||||||
|
.cache-vcl-guide-dialog {
|
||||||
|
width: calc(min(980px, 100vw - 24px) / var(--ui-scale, 1));
|
||||||
|
max-height: calc((100dvh - 28px) / var(--ui-scale, 1));
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.cache-guide-dialog-heading { justify-content: space-between; }
|
||||||
|
.cache-guide-dialog-heading h2 { margin: 3px 0 0; }
|
||||||
|
.cache-guide-content {
|
||||||
|
overflow-y: auto;
|
||||||
|
max-height: calc((100dvh - 110px) / var(--ui-scale, 1));
|
||||||
|
padding: 14px;
|
||||||
|
}
|
||||||
|
.cache-guide-content>.fine { margin: 0 0 12px; }
|
||||||
|
.cache-guide-current {
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
background: var(--panel2);
|
||||||
|
padding: 12px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
.cache-guide-current-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
|
||||||
|
.cache-guide-current p { margin: 5px 0 0; }
|
||||||
|
.cache-guide-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
align-items: stretch;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
.cache-guide-card {
|
||||||
|
min-width: 0;
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
background: var(--panel);
|
||||||
|
padding: 13px;
|
||||||
|
}
|
||||||
|
.cache-guide-card h3 { margin: 0 0 8px; font-size: 14px; }
|
||||||
|
.cache-guide-card p { font-size: 12px; line-height: 1.55; margin: 0; }
|
||||||
|
.cache-guide-card p+p { margin-top: 9px; }
|
||||||
|
.cache-guide-card pre {
|
||||||
|
margin: 9px 0;
|
||||||
|
padding: 10px;
|
||||||
|
max-width: 100%;
|
||||||
|
overflow: auto;
|
||||||
|
color: var(--text);
|
||||||
|
background: var(--panel2);
|
||||||
|
border: 1px solid var(--line);
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.5;
|
||||||
|
tab-size: 2;
|
||||||
|
}
|
||||||
|
.cache-guide-card pre code { white-space: pre; }
|
||||||
|
.cache-guide-import-example { margin-top: 4px; width: auto; }
|
||||||
|
.cache-guide-footer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 13px; }
|
||||||
|
.cache-guide-footer>.fine { flex: 1 1 100%; margin: 0; }
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.cache-guide-grid { grid-template-columns: minmax(0, 1fr); }
|
||||||
|
.cache-guide-content { padding: 10px; }
|
||||||
|
.cache-guide-card { padding: 11px; }
|
||||||
|
}
|
||||||
@@ -758,13 +758,13 @@
|
|||||||
if (!picked.length) return { acl_profile_ids: [], inherit_acl_profiles: !inherited.length };
|
if (!picked.length) return { acl_profile_ids: [], inherit_acl_profiles: !inherited.length };
|
||||||
return { acl_profile_ids: picked, inherit_acl_profiles: true };
|
return { acl_profile_ids: picked, inherit_acl_profiles: true };
|
||||||
}
|
}
|
||||||
function cacheEditor(assignment, agent, key, enabled) {
|
function cacheEditor(assignment, agent, key, enabled, testHost) {
|
||||||
const details = el("details", undefined, "docker-cache-editor"), summary = el("summary"); summary.append(el("span", t("dockerCacheSettings")), el("small", t("dockerCacheSettingsHelp"), "fine")); details.append(summary);
|
const details = el("details", undefined, "docker-cache-editor"), summary = el("summary"); summary.append(el("span", t("dockerCacheSettings")), el("small", t("dockerCacheSettingsHelp"), "fine")); details.append(summary);
|
||||||
const grid = el("div", undefined, "field-grid docker-cache-grid");
|
const grid = el("div", undefined, "field-grid docker-cache-grid");
|
||||||
const ttl = input(assignment?.cache_default_ttl_seconds ?? "", "number", "docker-cache-ttl"); ttl.min = 0; ttl.max = 31536000; ttl.placeholder = String(envelope?.config?.cache?.default_ttl_seconds ?? "");
|
const ttl = input(assignment?.cache_default_ttl_seconds ?? "", "number", "docker-cache-ttl"); ttl.min = 0; ttl.max = 31536000; ttl.placeholder = String(envelope?.config?.cache?.default_ttl_seconds ?? "");
|
||||||
grid.append(labeled("dockerCacheTtl", ttl, t("dockerCacheTtlHelp")));
|
grid.append(labeled("dockerCacheTtl", ttl, t("dockerCacheTtlHelp")));
|
||||||
const vhostId = poolRoutes.find(item => item.agent_id === agent.id && item.service_key === key)?.pool_id || "";
|
const vhostId = poolRoutes.find(item => item.agent_id === agent.id && item.service_key === key)?.pool_id || "";
|
||||||
const rules = window.rustProxyCacheRules?.create?.({ scope: "vhost", vhostId, rules: assignment?.cache_rules || [], ignoreGlobal: assignment?.cache_ignore_global_rules === true, ignoreId: "", autoLoadHits: false });
|
const rules = window.rustProxyCacheRules?.create?.({ scope: "vhost", vhostId, rules: assignment?.cache_rules || [], ignoreGlobal: assignment?.cache_ignore_global_rules === true, ignoreId: "", autoLoadHits: false, testHost });
|
||||||
if (rules?.node) { rules.node.classList.add("docker-cache-rules"); details._rules = rules; }
|
if (rules?.node) { rules.node.classList.add("docker-cache-rules"); details._rules = rules; }
|
||||||
details.append(grid); if (rules?.node) details.append(rules.node);
|
details.append(grid); if (rules?.node) details.append(rules.node);
|
||||||
details.addEventListener("toggle", () => { if (details.open && !details.hidden) void rules?.refreshHits?.(); });
|
details.addEventListener("toggle", () => { if (details.open && !details.hidden) void rules?.refreshHits?.(); });
|
||||||
@@ -1063,7 +1063,7 @@
|
|||||||
protocolOptions.append(h1, checkboxField("dockerHttp2Enabled", h2Enabled), checkboxField("dockerHttp3Enabled", h3Enabled));
|
protocolOptions.append(h1, checkboxField("dockerHttp2Enabled", h2Enabled), checkboxField("dockerHttp3Enabled", h3Enabled));
|
||||||
protocolBox.append(protocolSummary, protocolOptions);
|
protocolBox.append(protocolSummary, protocolOptions);
|
||||||
route.append(hostField, aliases.node, backendIpSettings, labeled("dockerBackendScheme", scheme), switches); syncHostHelp();
|
route.append(hostField, aliases.node, backendIpSettings, labeled("dockerBackendScheme", scheme), switches); syncHostHelp();
|
||||||
editor.append(route, protocolBox, aclEditor(assignment, agent), securityEditor(assignment), cacheEditor(assignment, agent, key, cacheEnabled), diagnosticsEditor(assignment), timeoutEditor(assignment), healthEditor(assignment), passiveHealthEditor(assignment));
|
editor.append(route, protocolBox, aclEditor(assignment, agent), securityEditor(assignment), cacheEditor(assignment, agent, key, cacheEnabled, () => expandedHost(host.value.trim() || technical, domainSelect.value)), diagnosticsEditor(assignment), timeoutEditor(assignment), healthEditor(assignment), passiveHealthEditor(assignment));
|
||||||
const actions = el("div", undefined, "docker-service-actions"); apply = el("button", t("dockerApplyService"), "outline docker-apply"); apply.type = "button"; apply.disabled = !publish.checked; apply.addEventListener("click", async () => { apply.disabled = true; try { await saveAssignment(agent.id, row, true); } catch (error) { toast(error.message, true); } finally { if (row.isConnected) apply.disabled = !publish.checked; } }); actions.append(apply); editor.append(actions);
|
const actions = el("div", undefined, "docker-service-actions"); apply = el("button", t("dockerApplyService"), "outline docker-apply"); apply.type = "button"; apply.disabled = !publish.checked; apply.addEventListener("click", async () => { apply.disabled = true; try { await saveAssignment(agent.id, row, true); } catch (error) { toast(error.message, true); } finally { if (row.isConnected) apply.disabled = !publish.checked; } }); actions.append(apply); editor.append(actions);
|
||||||
function updateHint() { syncCertificateHint(); editorHint.textContent = hintFor({ hostname: host.value.trim(), domain: domainSelect.value, targetLabel: target.selectedOptions?.[0]?.textContent || t("dockerBackendIpAuto"), scheme: scheme.value, h2: h2Enabled.checked, h3: h3Enabled.checked, aliasCount: aliases.count() }); } updateHint();
|
function updateHint() { syncCertificateHint(); editorHint.textContent = hintFor({ hostname: host.value.trim(), domain: domainSelect.value, targetLabel: target.selectedOptions?.[0]?.textContent || t("dockerBackendIpAuto"), scheme: scheme.value, h2: h2Enabled.checked, h3: h3Enabled.checked, aliasCount: aliases.count() }); } updateHint();
|
||||||
for (const control of [host, aliases.input, target, scheme]) { control.addEventListener("input", updateHint); control.addEventListener("change", updateHint); }
|
for (const control of [host, aliases.input, target, scheme]) { control.addEventListener("input", updateHint); control.addEventListener("change", updateHint); }
|
||||||
|
|||||||
+138
-14
@@ -2739,8 +2739,12 @@
|
|||||||
hidden="" id="settings-page-cache" role="tabpanel">
|
hidden="" id="settings-page-cache" role="tabpanel">
|
||||||
<form class="card edit-form" id="cache-form">
|
<form class="card edit-form" id="cache-form">
|
||||||
<div class="card-heading">
|
<div class="card-heading">
|
||||||
<h2 data-i18n="cacheSettings">Cache</h2><span class="pill live"
|
<h2 data-i18n="cacheSettings">Cache</h2>
|
||||||
data-i18n="hotApply">LIVE APPLY</span>
|
<div class="cache-guide-heading-actions">
|
||||||
|
<button class="outline cache-guide-trigger" type="button"
|
||||||
|
data-i18n="cacheGuideOpen">Cache & VCL guide</button>
|
||||||
|
<span class="pill live" data-i18n="hotApply">LIVE APPLY</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<nav aria-label="Cache settings" class="settings-tabs sub-tabs" id="cache-settings-tabs"
|
<nav aria-label="Cache settings" class="settings-tabs sub-tabs" id="cache-settings-tabs"
|
||||||
role="tablist">
|
role="tablist">
|
||||||
@@ -2761,6 +2765,8 @@
|
|||||||
href="/docs#doc=docs%2FCACHE.md&section=cache-rules-vcl-style"
|
href="/docs#doc=docs%2FCACHE.md&section=cache-rules-vcl-style"
|
||||||
target="_blank" rel="noopener noreferrer" data-i18n="cacheRulesDocs">Cache rules
|
target="_blank" rel="noopener noreferrer" data-i18n="cacheRulesDocs">Cache rules
|
||||||
documentation</a>
|
documentation</a>
|
||||||
|
<button class="outline cache-guide-trigger" type="button"
|
||||||
|
data-i18n="cacheGuideOpen">Cache & VCL guide</button>
|
||||||
<div id="cache-rules-root"></div>
|
<div id="cache-rules-root"></div>
|
||||||
</div>
|
</div>
|
||||||
<div data-cache-settings-page="general">
|
<div data-cache-settings-page="general">
|
||||||
@@ -2768,10 +2774,10 @@
|
|||||||
</h3>
|
</h3>
|
||||||
<label class="check"><input class="switch" id="cache-enabled" type="checkbox" /><span
|
<label class="check"><input class="switch" id="cache-enabled" type="checkbox" /><span
|
||||||
data-i18n="enableCache">Enable shared cache</span></label>
|
data-i18n="enableCache">Enable shared cache</span></label>
|
||||||
<p class="fine" data-i18n="cacheSafety">Only complete public-safe GET responses.
|
<p class="fine" data-i18n="cacheSafety">Only eligible GET/HEAD responses.
|
||||||
Authorization, cookies and private/no-store responses still bypass the cache.
|
Authorization and private/no-store responses bypass storage. Cookies normally
|
||||||
One byte range can be served from a complete cached object;
|
bypass unless an eligible compatible VCL rule explicitly opts in. A single range
|
||||||
multipart/unsupported ranges pass through.</p>
|
may use a complete cached object; unsupported ranges bypass.</p>
|
||||||
<div class="cache-varnish-setting">
|
<div class="cache-varnish-setting">
|
||||||
<label class="check"><input class="switch" id="cache-varnish-compatible"
|
<label class="check"><input class="switch" id="cache-varnish-compatible"
|
||||||
type="checkbox" /><span
|
type="checkbox" /><span
|
||||||
@@ -2790,12 +2796,15 @@
|
|||||||
during grace); existing cookie rules, Authorization, Vary,
|
during grace); existing cookie rules, Authorization, Vary,
|
||||||
PURGE/BAN, HOT/COLD and transformations stay active.</p>
|
PURGE/BAN, HOT/COLD and transformations stay active.</p>
|
||||||
<p class="fine" data-i18n="cacheVarnishCompatibleBackendHelp">Origin
|
<p class="fine" data-i18n="cacheVarnishCompatibleBackendHelp">Origin
|
||||||
no-cache with a validator remains revalidatable. If an explicit
|
no-cache with ETag/Last-Modified remains revalidatable. With a
|
||||||
fallback TTL is set, public no-cache responses may instead be reused
|
positive fallback TTL, compatible mode can cache eligible no-cache
|
||||||
for that TTL, even without a validator. Private/no-store/Set-Cookie
|
responses even without public or a validator. Private, no-store,
|
||||||
and Surrogate-Control: no-store remain blocked. Zero-TTL objects may
|
Set-Cookie and Surrogate-Control: no-store remain blocked.
|
||||||
be retained for stale-if-error or revalidation; explicit
|
This is a configured override, not vanilla Varnish behavior.</p>
|
||||||
stale-while-revalidate=0 is respected.</p>
|
<p class="fine" data-i18n="cacheVarnishCompatibleVclHelp">Use
|
||||||
|
return(pass) for session cookies before return(hash) for selected
|
||||||
|
public routes. In Rules, the Cache & VCL guide explains Vary,
|
||||||
|
header edits and importer limits. Per-vhost overrides take precedence.</p>
|
||||||
<p class="fine" data-i18n="cacheVarnishCompatibleModeHelp">Implicit
|
<p class="fine" data-i18n="cacheVarnishCompatibleModeHelp">Implicit
|
||||||
grace (60 seconds by default, configurable below) only applies to
|
grace (60 seconds by default, configurable below) only applies to
|
||||||
eligible fresh-at-storage responses without an explicit
|
eligible fresh-at-storage responses without an explicit
|
||||||
@@ -2811,8 +2820,7 @@
|
|||||||
<input id="cache-varnish-grace" type="number" min="0" max="604800" step="1"
|
<input id="cache-varnish-grace" type="number" min="0" max="604800" step="1"
|
||||||
required />
|
required />
|
||||||
</div>
|
</div>
|
||||||
<label data-i18n="cacheDefaultTtl" for="cache-default-ttl">Fallback TTL for public
|
<label data-i18n="cacheDefaultTtl" for="cache-default-ttl">Fallback TTL (seconds): public, or headerless/no-cache in compatibility mode (0 = off)</label><input id="cache-default-ttl" max="604800" min="0"
|
||||||
responses (0 = off)</label><input id="cache-default-ttl" max="604800" min="0"
|
|
||||||
required="" type="number" />
|
required="" type="number" />
|
||||||
<label class="check"><input class="switch" id="cache-query" type="checkbox" /><span
|
<label class="check"><input class="switch" id="cache-query" type="checkbox" /><span
|
||||||
data-i18n="bypassQuery">Bypass URLs with a query string</span></label>
|
data-i18n="bypassQuery">Bypass URLs with a query string</span></label>
|
||||||
@@ -4126,6 +4134,122 @@
|
|||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
<dialog aria-labelledby="cache-vcl-guide-title" aria-modal="true"
|
||||||
|
class="vhost-dialog cache-vcl-guide-dialog" id="cache-vcl-guide-dialog">
|
||||||
|
<div class="window-heading cache-guide-dialog-heading">
|
||||||
|
<div>
|
||||||
|
<span class="small-label" data-i18n="cacheGuideEyebrow">CACHE SETTINGS · VCL SUBSET</span>
|
||||||
|
<h2 data-i18n="cacheGuideTitle" id="cache-vcl-guide-title">Practical cache & VCL guide</h2>
|
||||||
|
</div>
|
||||||
|
<button class="outline" data-i18n="close" id="cache-vcl-guide-close" type="button">Close</button>
|
||||||
|
</div>
|
||||||
|
<div class="cache-guide-content">
|
||||||
|
<p class="fine" data-i18n="cacheGuideIntro">Practical notes for RustProxy, not a promise of complete Varnish VCL compatibility. Only imported and accepted rules are executed.</p>
|
||||||
|
<div class="cache-guide-current" role="status" aria-live="polite">
|
||||||
|
<div class="cache-guide-current-pills">
|
||||||
|
<span class="pill" id="cache-guide-mode"></span>
|
||||||
|
<span class="pill" id="cache-guide-ttl"></span>
|
||||||
|
<span class="pill" id="cache-guide-grace"></span>
|
||||||
|
<span class="pill" id="cache-guide-context"></span>
|
||||||
|
</div>
|
||||||
|
<p class="fine" id="cache-guide-current-note"></p>
|
||||||
|
<p class="fine" id="cache-guide-scope-note"></p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideUnsaved">Values reflect the current form, which may contain unsaved changes.</p>
|
||||||
|
</div>
|
||||||
|
<div class="cache-guide-grid">
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideFreshnessTitle">no-cache, TTL and grace</h3>
|
||||||
|
<p data-i18n="cacheGuideFreshnessText">With Varnish compatibility and a positive fallback TTL, an eligible Cache-Control: no-cache response can be served as HIT for that TTL without public. With compatibility off, no-cache requires validation before reuse. Grace is a separate stale-response window, not a fallback TTL.</p>
|
||||||
|
<pre><code>Cache-Control: no-cache
|
||||||
|
Fallback TTL: 60 s
|
||||||
|
Varnish-compatible: ON</code></pre>
|
||||||
|
<p class="fine" data-i18n="cacheGuideFreshnessWarning">Do not expect a HIT for private/no-store/Set-Cookie or when the request is BYPASS. This override is not the default Varnish VCL behavior.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideCookieTitle">Cookie and return(hash)</h3>
|
||||||
|
<p data-i18n="cacheGuideCookieText">Cookies normally trigger BYPASS. In compatible mode, an explicit return(hash) can admit eligible Cookie requests; the full Cookie remains on the backend request and partitions the cache. Catch session cookies with return(pass) first.</p>
|
||||||
|
<pre><code>sub vcl_recv {
|
||||||
|
if (req.http.Cookie ~ "session=") {
|
||||||
|
return (pass);
|
||||||
|
}
|
||||||
|
if (req.url ~ "^/public/") {
|
||||||
|
return (hash);
|
||||||
|
}
|
||||||
|
}</code></pre>
|
||||||
|
<button class="outline cache-guide-import-example" type="button"
|
||||||
|
data-i18n="cacheGuideInsert">Insert into VCL importer</button>
|
||||||
|
<p class="fine" data-i18n="cacheGuideCookieWarning">unset req.http.Cookie removes ALL cookies, including from the request sent to the backend. Authorization and authentication protections still apply.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideVaryTitle">Vary and cache variants</h3>
|
||||||
|
<p data-i18n="cacheGuideVaryText">set/unset beresp.http.Vary changes variant selection before storing. set/unset resp.http.Vary only changes what the client sees; it does not repair the stored cache key. An assignment replaces the whole Vary list.</p>
|
||||||
|
<pre><code>sub vcl_backend_response {
|
||||||
|
set beresp.http.Vary =
|
||||||
|
"Accept-Encoding, Accept-Language";
|
||||||
|
}
|
||||||
|
sub vcl_deliver {
|
||||||
|
unset resp.http.X-Powered-By;
|
||||||
|
}</code></pre>
|
||||||
|
<button class="outline cache-guide-import-example" type="button"
|
||||||
|
data-i18n="cacheGuideInsert">Insert into VCL importer</button>
|
||||||
|
<p class="fine" data-i18n="cacheGuideVaryWarning">Never remove a required Vary dimension for a personalized or encoded response. RustProxy may restore Vary: Cookie for cookie-partitioned objects; static Ignore Vary: Cookie requires public and other safety checks.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideHeadersTitle">set/unset headers</h3>
|
||||||
|
<p data-i18n="cacheGuideHeadersText">beresp.http.* edits the backend response before the cache decision; resp.http.* edits only the delivered response. Removing beresp.http.Cache-Control can change cache eligibility, while removing resp.http.Cache-Control cannot.</p>
|
||||||
|
<pre><code>sub vcl_backend_response {
|
||||||
|
unset beresp.http.X-Debug;
|
||||||
|
set beresp.http.Cache-Control =
|
||||||
|
"public, max-age=60";
|
||||||
|
}
|
||||||
|
sub vcl_deliver {
|
||||||
|
unset resp.http.X-Powered-By;
|
||||||
|
}</code></pre>
|
||||||
|
<button class="outline cache-guide-import-example" type="button"
|
||||||
|
data-i18n="cacheGuideInsert">Insert into VCL importer</button>
|
||||||
|
<p class="fine" data-i18n="cacheGuideHeadersWarning">Only literal string assignments are imported; protected transport/body headers cannot be edited. Removing Set-Cookie requires a dedicated backend action and is unsafe for session responses.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideRequestTitle">Request headers and storage overrides</h3>
|
||||||
|
<p data-i18n="cacheGuideRequestText">Safe set/unset req.http headers are applied before subsequent rules, hashing and forwarding to the origin. beresp.uncacheable = false reverses an earlier rule's no-store decision, but does not override origin private/no-store/Set-Cookie.</p>
|
||||||
|
<pre><code>sub vcl_recv {
|
||||||
|
unset req.http.X-Tracking;
|
||||||
|
set req.http.X-Device = "mobile";
|
||||||
|
}
|
||||||
|
sub vcl_backend_response {
|
||||||
|
set beresp.uncacheable = false;
|
||||||
|
}</code></pre>
|
||||||
|
<button class="outline cache-guide-import-example" type="button"
|
||||||
|
data-i18n="cacheGuideInsert">Insert into VCL importer</button>
|
||||||
|
<p class="fine" data-i18n="cacheGuideRequestWarning">Authorization, Cookie (except dedicated unset), Cache-Control and forwarding/transport headers are protected in request rules. Complex URL rewrites are warned about, not guessed. Always review import warnings.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideUncacheableDifference">RustProxy's beresp.uncacheable = false applies only to a previous cache-rule restriction; this is not Varnish's exact behavior. The backend's private/no-store and Set-Cookie protections remain unless deliberately rewritten by a separate trusted rule.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideStagesTitle">VCL stages and rule precedence</h3>
|
||||||
|
<p data-i18n="cacheGuideStagesText">vcl_recv handles pass/hash and request rewrites; vcl_hash supports selected hash_data(req.http.X); vcl_backend_response handles TTL, grace and backend headers; vcl_deliver edits final headers, even on HIT or BYPASS.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuidePrecedenceText">Rules for the vhost are evaluated before matching global rules. Per-vhost changes win on conflicting supported settings and headers, or global rules may be disabled for the vhost. Importing VCL converts it into graphical rules; review warnings and the resulting order before saving.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideUnsupportedText">Not yet a full Varnish interpreter: vcl_hit/vcl_miss/vcl_pass hooks, arbitrary sub/call, VMOD, ACL expressions, beresp.keep, hit-for-miss/pass, restart, retry, synth and purge are not executed as VCL.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideBuiltInHash">hash_data(req.url) and hash_data(req.http.Host) are already included in the internal cache key. vcl_hash can add one extra req.http.* header, but it does not automatically generate a matching Vary header.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideStatusRestriction">RustProxy currently stores only HTTP 200 responses. A TTL rule for 404/301 does not enable caching of those statuses; the former 404 template was removed to avoid suggesting otherwise.</p>
|
||||||
|
<p class="fine" data-i18n="cacheGuideVclPreviewWarning">VCL export is a readable preview, not a lossless round-trip. If import reports warnings, rules are not added until you explicitly accept the partial result. Editing the source or closing the importer discards any pending import.</p>
|
||||||
|
</section>
|
||||||
|
<section class="cache-guide-card">
|
||||||
|
<h3 data-i18n="cacheGuideDiagnoseTitle">Why isn't it a HIT?</h3>
|
||||||
|
<p data-i18n="cacheGuideDiagnoseText">Enable X-Cache and detailed reason headers; disable Only on HIT while debugging. Send two identical GET requests with curl (not a browser hard reload), then compare the cache outcome and origin headers.</p>
|
||||||
|
<pre><code>curl -sS -D - -o /dev/null \
|
||||||
|
https://example.com/public/page
|
||||||
|
curl -sS -D - -o /dev/null \
|
||||||
|
https://example.com/public/page</code></pre>
|
||||||
|
<p class="fine" data-i18n="cacheGuideDiagnoseReasons">BYPASS usually means request exclusion (Cookie, Authorization, route or query). MISS means the backend was contacted, but does not prove that the response was stored. Check X-Cache-Reason, Cache-Control, Set-Cookie, Vary and Age.</p>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<div class="cache-guide-footer">
|
||||||
|
<p class="fine" data-i18n="cacheGuideScope">These VCL rules affect reverse-proxy vhosts; they do not execute on the embedded administration panel or all Web Server sources. Test on a non-production vhost first.</p>
|
||||||
|
<a class="docs-link" href="/docs#doc=docs%2FVCL.md" target="_blank" rel="noopener noreferrer" data-i18n="cacheGuideDocsVcl">Complete supported VCL syntax and limits</a>
|
||||||
|
<a class="docs-link" href="/docs#doc=docs%2FCACHE.md" target="_blank" rel="noopener noreferrer" data-i18n="cacheGuideDocsCache">HTTP cache policy and diagnostics</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</dialog>
|
||||||
<dialog aria-labelledby="cache-invalidation-title" class="vhost-dialog cache-operation-dialog"
|
<dialog aria-labelledby="cache-invalidation-title" class="vhost-dialog cache-operation-dialog"
|
||||||
id="cache-invalidation-dialog">
|
id="cache-invalidation-dialog">
|
||||||
<article class="card">
|
<article class="card">
|
||||||
|
|||||||
@@ -103,6 +103,54 @@
|
|||||||
button.addEventListener("keydown", event => { const index = cacheTabs.indexOf(button); let next; if (event.key === "ArrowRight" || event.key === "ArrowDown") next = (index + 1) % cacheTabs.length; else if (event.key === "ArrowLeft" || event.key === "ArrowUp") next = (index + cacheTabs.length - 1) % cacheTabs.length; else if (event.key === "Home") next = 0; else if (event.key === "End") next = cacheTabs.length - 1; else return; event.preventDefault(); selectCacheTab(cacheTabs[next].dataset.cacheSettingsTab, true); });
|
button.addEventListener("keydown", event => { const index = cacheTabs.indexOf(button); let next; if (event.key === "ArrowRight" || event.key === "ArrowDown") next = (index + 1) % cacheTabs.length; else if (event.key === "ArrowLeft" || event.key === "ArrowUp") next = (index + cacheTabs.length - 1) % cacheTabs.length; else if (event.key === "Home") next = 0; else if (event.key === "End") next = cacheTabs.length - 1; else return; event.preventDefault(); selectCacheTab(cacheTabs[next].dataset.cacheSettingsTab, true); });
|
||||||
}
|
}
|
||||||
selectCacheTab("general");
|
selectCacheTab("general");
|
||||||
|
const cacheGuideDialog = $("cache-vcl-guide-dialog");
|
||||||
|
let guideEditor = null;
|
||||||
|
let guideIsLocal = false;
|
||||||
|
function openCacheGuide(trigger) {
|
||||||
|
if (!cacheGuideDialog) return;
|
||||||
|
// One guide serves the static global editor and both dynamic vhost editors.
|
||||||
|
// Keep its destination tied to the button that opened it; never silently
|
||||||
|
// insert a vhost example into global rules or vice versa.
|
||||||
|
guideEditor = trigger?.closest(".cache-rules") || $("cache-rules-root")?.querySelector(".cache-rules") || null;
|
||||||
|
guideIsLocal = guideEditor?.classList.contains("cache-rules-vhost") === true;
|
||||||
|
const isDocker = guideIsLocal && !!guideEditor.closest(".docker-cache-editor");
|
||||||
|
const compatible = $("cache-varnish-compatible").checked;
|
||||||
|
const enabled = $("cache-enabled").checked;
|
||||||
|
const ttl = Math.max(0, Number($("cache-default-ttl").value) || 0);
|
||||||
|
const grace = Math.max(0, Number($("cache-varnish-grace").value) || 0);
|
||||||
|
const mode = $("cache-guide-mode");
|
||||||
|
mode.textContent = t(compatible ? "cacheGuideModeOn" : "cacheGuideModeOff");
|
||||||
|
mode.classList.toggle("live", compatible);
|
||||||
|
$("cache-guide-ttl").textContent = t("cacheGuideTtlStatus").replace("{seconds}", ttl);
|
||||||
|
$("cache-guide-grace").textContent = t("cacheGuideGraceStatus").replace("{seconds}", grace);
|
||||||
|
$("cache-guide-current-note").textContent = t(!enabled ? "cacheGuideCacheOffNote" : !compatible ? "cacheGuideRfcNote" : ttl > 0 ? "cacheGuideCompatNote" : "cacheGuideCompatZeroNote");
|
||||||
|
$("cache-guide-context").textContent = t(isDocker ? "cacheGuideContextDocker" : guideIsLocal ? "cacheGuideContextVhost" : "cacheGuideContextGlobal");
|
||||||
|
$("cache-guide-scope-note").textContent = t(isDocker ? "cacheGuideScopeDocker" : guideIsLocal ? "cacheGuideScopeVhost" : "cacheGuideScopeGlobal");
|
||||||
|
if (!cacheGuideDialog.open) cacheGuideDialog.showModal();
|
||||||
|
}
|
||||||
|
// Event delegation is needed: the ordinary vhost dialog and the Docker
|
||||||
|
// service editors are created after settings.js has registered its events.
|
||||||
|
document.addEventListener("click", event => {
|
||||||
|
const button = event.target.closest?.(".cache-guide-trigger");
|
||||||
|
if (!button) return;
|
||||||
|
event.preventDefault();
|
||||||
|
openCacheGuide(button);
|
||||||
|
});
|
||||||
|
$("cache-vcl-guide-close")?.addEventListener("click", () => cacheGuideDialog.close());
|
||||||
|
cacheGuideDialog?.querySelectorAll(".cache-guide-import-example").forEach(button => button.addEventListener("click", () => {
|
||||||
|
const source = button.closest(".cache-guide-card")?.querySelector("pre code")?.textContent?.trim();
|
||||||
|
const importer = guideEditor?.isConnected ? guideEditor.querySelector(".cache-rules-import") : null;
|
||||||
|
const editor = importer?.querySelector("textarea");
|
||||||
|
if (!source || !editor) { toast(t("cacheGuideImporterUnavailable"), true); return; }
|
||||||
|
editor.value = [editor.value.trim(), source].filter(Boolean).join("\n\n");
|
||||||
|
// Invalidates any pending partial-import preview from an older source.
|
||||||
|
editor.dispatchEvent(new Event("input", { bubbles: true }));
|
||||||
|
importer.hidden = false;
|
||||||
|
cacheGuideDialog.close();
|
||||||
|
if (!guideIsLocal) selectCacheTab("rules");
|
||||||
|
importer.scrollIntoView({ block: "nearest", behavior: "smooth" });
|
||||||
|
editor.focus({ preventScroll: true });
|
||||||
|
}));
|
||||||
const loggingTabs = [...document.querySelectorAll("[data-logging-settings-tab]")];
|
const loggingTabs = [...document.querySelectorAll("[data-logging-settings-tab]")];
|
||||||
function selectLoggingTab(name, focus = false) {
|
function selectLoggingTab(name, focus = false) {
|
||||||
if (!loggingTabs.some(button => button.dataset.loggingSettingsTab === name)) return;
|
if (!loggingTabs.some(button => button.dataset.loggingSettingsTab === name)) return;
|
||||||
|
|||||||
@@ -536,7 +536,10 @@ function load(value = defaults(), migrationIds = [], show = true) {
|
|||||||
note(unsafeCacheFields, "vhCacheForceHelp");
|
note(unsafeCacheFields, "vhCacheForceHelp");
|
||||||
const cacheRulesFields = el("div", undefined, "vh-wide vh-cache-rules"); cacheOptions.append(cacheRulesFields);
|
const cacheRulesFields = el("div", undefined, "vh-wide vh-cache-rules"); cacheOptions.append(cacheRulesFields);
|
||||||
cacheRulesFields.append(el("h4", t("vhCacheRulesTitle")), el("p", t("vhCacheRulesHelp"), "fine"));
|
cacheRulesFields.append(el("h4", t("vhCacheRulesTitle")), el("p", t("vhCacheRulesHelp"), "fine"));
|
||||||
vhostCacheRulesEditor = window.rustProxyCacheRules.create({ scope: "vhost", vhostId: editing || "", rules: cache.rules || [], ignoreGlobal: cache.ignore_global_rules === true });
|
vhostCacheRulesEditor = window.rustProxyCacheRules.create({
|
||||||
|
scope: "vhost", vhostId: editing || "", rules: cache.rules || [], ignoreGlobal: cache.ignore_global_rules === true,
|
||||||
|
testHost: () => lines(read("hosts")?.value || "").find(host => host && !host.startsWith("*.")) || "",
|
||||||
|
});
|
||||||
cacheRulesFields.append(vhostCacheRulesEditor.node);
|
cacheRulesFields.append(vhostCacheRulesEditor.node);
|
||||||
if (editing) cacheOptions.append(button("vhPurgeCache", () => purge(editing)));
|
if (editing) cacheOptions.append(button("vhPurgeCache", () => purge(editing)));
|
||||||
const syncCacheVisibility = () => {
|
const syncCacheVisibility = () => {
|
||||||
|
|||||||
Vendored
+16
-1
@@ -215,6 +215,20 @@ pub fn request_policy(
|
|||||||
path: &str,
|
path: &str,
|
||||||
has_query: bool,
|
has_query: bool,
|
||||||
settings: &Settings,
|
settings: &Settings,
|
||||||
|
) -> RequestPolicy {
|
||||||
|
request_policy_with_vcl_cookie(method, headers, empty_body, path, has_query, settings, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// VCL return(hash) may override the built-in Cookie pass only in compatibility
|
||||||
|
/// mode. Authorization, no-store, invalid methods and other guards remain.
|
||||||
|
pub fn request_policy_with_vcl_cookie(
|
||||||
|
method: &Method,
|
||||||
|
headers: &HeaderMap,
|
||||||
|
empty_body: bool,
|
||||||
|
path: &str,
|
||||||
|
has_query: bool,
|
||||||
|
settings: &Settings,
|
||||||
|
allow_cookie: bool,
|
||||||
) -> RequestPolicy {
|
) -> RequestPolicy {
|
||||||
if method != Method::GET && method != Method::HEAD {
|
if method != Method::GET && method != Method::HEAD {
|
||||||
return RequestPolicy::Bypass("request_method");
|
return RequestPolicy::Bypass("request_method");
|
||||||
@@ -246,7 +260,8 @@ pub fn request_policy(
|
|||||||
("upgrade", "request_upgrade"),
|
("upgrade", "request_upgrade"),
|
||||||
] {
|
] {
|
||||||
if headers.contains_key(key) {
|
if headers.contains_key(key) {
|
||||||
if key == "cookie" && settings.ignore_cookie_for_path(path) {
|
if key == "cookie" && (settings.ignore_cookie_for_path(path)
|
||||||
|
|| (settings.varnish_compatible && allow_cookie)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return RequestPolicy::Bypass(reason);
|
return RequestPolicy::Bypass(reason);
|
||||||
|
|||||||
Vendored
+10
-5
@@ -187,12 +187,13 @@ pub fn plan_with(
|
|||||||
if !forced && settings.varnish_compatible && surrogate_no_store(headers) {
|
if !forced && settings.varnish_compatible && surrogate_no_store(headers) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let override_public_no_cache = settings.varnish_compatible
|
// Explicit compatibility-mode fallback overrides origin no-cache even when
|
||||||
|
// it does not contain public. Strict mode always follows RFC 9111.
|
||||||
|
let override_no_cache = settings.varnish_compatible
|
||||||
&& control.contains_key("no-cache")
|
&& control.contains_key("no-cache")
|
||||||
&& control.contains_key("public")
|
&& (settings.default_ttl_seconds > 0 || overrides.ttl.is_some_and(|ttl| ttl > 0));
|
||||||
&& settings.default_ttl_seconds > 0;
|
|
||||||
let requires_revalidation =
|
let requires_revalidation =
|
||||||
!forced && control.contains_key("no-cache") && !override_public_no_cache;
|
!forced && control.contains_key("no-cache") && !override_no_cache;
|
||||||
let must_revalidate = !forced && control.contains_key("must-revalidate");
|
let must_revalidate = !forced && control.contains_key("must-revalidate");
|
||||||
let proxy_revalidate = !forced && control.contains_key("proxy-revalidate");
|
let proxy_revalidate = !forced && control.contains_key("proxy-revalidate");
|
||||||
let parse_window = |name: &str| -> Option<u64> {
|
let parse_window = |name: &str| -> Option<u64> {
|
||||||
@@ -219,7 +220,7 @@ pub fn plan_with(
|
|||||||
Some(ttl)
|
Some(ttl)
|
||||||
} else if forced {
|
} else if forced {
|
||||||
(settings.default_ttl_seconds > 0).then_some(settings.default_ttl_seconds)
|
(settings.default_ttl_seconds > 0).then_some(settings.default_ttl_seconds)
|
||||||
} else if override_public_no_cache {
|
} else if override_no_cache {
|
||||||
Some(settings.default_ttl_seconds)
|
Some(settings.default_ttl_seconds)
|
||||||
} else if let Some(value) = control.get("s-maxage").or_else(|| control.get("max-age")) {
|
} else if let Some(value) = control.get("s-maxage").or_else(|| control.get("max-age")) {
|
||||||
Some(value.as_ref()?.parse::<u64>().ok()?)
|
Some(value.as_ref()?.parse::<u64>().ok()?)
|
||||||
@@ -233,6 +234,10 @@ pub fn plan_with(
|
|||||||
)
|
)
|
||||||
} else if control.contains_key("public") {
|
} else if control.contains_key("public") {
|
||||||
Some(settings.default_ttl_seconds)
|
Some(settings.default_ttl_seconds)
|
||||||
|
} else if settings.varnish_compatible && settings.default_ttl_seconds > 0 {
|
||||||
|
// In compatibility mode a configured default TTL can also be used
|
||||||
|
// for headerless, otherwise eligible 200s (Varnish default_ttl style).
|
||||||
|
Some(settings.default_ttl_seconds)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+273
-64
@@ -23,6 +23,30 @@ const PROTECTED_RULE_HEADERS: &[&str] = &[
|
|||||||
"alt-svc",
|
"alt-svc",
|
||||||
];
|
];
|
||||||
|
|
||||||
|
/// Restrict request-side VCL mutations to representation headers. Identity,
|
||||||
|
/// authorization, cache directives and transport framing must remain under
|
||||||
|
/// RustProxy's normal request/security policy.
|
||||||
|
fn request_rule_header_name(value: &str) -> Result<http::HeaderName> {
|
||||||
|
let header = rule_header_name(value)?;
|
||||||
|
let name = header.as_str();
|
||||||
|
ensure!(
|
||||||
|
!PROTECTED_RULE_HEADERS.contains(&name)
|
||||||
|
&& !matches!(name,
|
||||||
|
"authorization" | "cookie" | "cache-control" | "pragma" |
|
||||||
|
"range" | "if-match" | "if-none-match" | "if-modified-since" |
|
||||||
|
"if-unmodified-since" | "if-range" | "forwarded" | "via" |
|
||||||
|
"x-real-ip" | "x-client-ip" | "true-client-ip" | "cf-connecting-ip" |
|
||||||
|
"content-type" | "expect")
|
||||||
|
&& !name.starts_with("x-forwarded-")
|
||||||
|
&& !name.starts_with("proxy-")
|
||||||
|
&& !name.starts_with("x-rustproxy-")
|
||||||
|
&& !name.starts_with("sec-")
|
||||||
|
&& !name.starts_with("if-"),
|
||||||
|
"request header {header} cannot be changed by cache rules"
|
||||||
|
);
|
||||||
|
Ok(header)
|
||||||
|
}
|
||||||
|
|
||||||
fn yes_rule() -> bool {
|
fn yes_rule() -> bool {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -122,6 +146,10 @@ pub struct RuleCondition {
|
|||||||
#[serde(tag = "type", rename_all = "snake_case", deny_unknown_fields)]
|
#[serde(tag = "type", rename_all = "snake_case", deny_unknown_fields)]
|
||||||
pub enum RuleAction {
|
pub enum RuleAction {
|
||||||
Pass,
|
Pass,
|
||||||
|
/// Explicit VCL return(hash): allow a Cookie-bearing request to reach lookup.
|
||||||
|
Lookup,
|
||||||
|
SetRequestHeader { name: String, value: String },
|
||||||
|
RemoveRequestHeader { name: String },
|
||||||
StripCookies {
|
StripCookies {
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
keep: Vec<String>,
|
keep: Vec<String>,
|
||||||
@@ -145,8 +173,13 @@ pub enum RuleAction {
|
|||||||
seconds: u64,
|
seconds: u64,
|
||||||
},
|
},
|
||||||
NoStore,
|
NoStore,
|
||||||
|
/// Reverse an earlier rule NoStore without bypassing origin privacy guards.
|
||||||
|
AllowStore,
|
||||||
IgnoreCacheControl,
|
IgnoreCacheControl,
|
||||||
StripSetCookie,
|
StripSetCookie,
|
||||||
|
/// Rewrite a backend header before determining cacheability and delivery.
|
||||||
|
SetBackendHeader { name: String, value: String },
|
||||||
|
RemoveBackendHeader { name: String },
|
||||||
SetHeader {
|
SetHeader {
|
||||||
name: String,
|
name: String,
|
||||||
value: String,
|
value: String,
|
||||||
@@ -164,6 +197,9 @@ impl RuleAction {
|
|||||||
fn stage(&self) -> RuleStage {
|
fn stage(&self) -> RuleStage {
|
||||||
match self {
|
match self {
|
||||||
Self::Pass
|
Self::Pass
|
||||||
|
| Self::Lookup
|
||||||
|
| Self::SetRequestHeader { .. }
|
||||||
|
| Self::RemoveRequestHeader { .. }
|
||||||
| Self::StripCookies { .. }
|
| Self::StripCookies { .. }
|
||||||
| Self::StripQuery { .. }
|
| Self::StripQuery { .. }
|
||||||
| Self::HashHeader { .. }
|
| Self::HashHeader { .. }
|
||||||
@@ -171,8 +207,11 @@ impl RuleAction {
|
|||||||
Self::Ttl { .. }
|
Self::Ttl { .. }
|
||||||
| Self::Grace { .. }
|
| Self::Grace { .. }
|
||||||
| Self::NoStore
|
| Self::NoStore
|
||||||
|
| Self::AllowStore
|
||||||
| Self::IgnoreCacheControl
|
| Self::IgnoreCacheControl
|
||||||
| Self::StripSetCookie => RuleStage::Response,
|
| Self::StripSetCookie
|
||||||
|
| Self::SetBackendHeader { .. }
|
||||||
|
| Self::RemoveBackendHeader { .. } => RuleStage::Response,
|
||||||
Self::SetHeader { .. } | Self::RemoveHeader { .. } | Self::DefaultHeader { .. } => {
|
Self::SetHeader { .. } | Self::RemoveHeader { .. } | Self::DefaultHeader { .. } => {
|
||||||
RuleStage::Deliver
|
RuleStage::Deliver
|
||||||
}
|
}
|
||||||
@@ -180,10 +219,12 @@ impl RuleAction {
|
|||||||
}
|
}
|
||||||
fn aspect(&self) -> Option<&'static str> {
|
fn aspect(&self) -> Option<&'static str> {
|
||||||
match self {
|
match self {
|
||||||
Self::Pass => Some("pass"),
|
Self::Pass | Self::Lookup => Some("request_routing"),
|
||||||
|
Self::StripCookies { .. } => Some("request_cookies"),
|
||||||
|
Self::StripQuery { .. } => Some("request_query"),
|
||||||
Self::Ttl { .. } => Some("ttl"),
|
Self::Ttl { .. } => Some("ttl"),
|
||||||
Self::Grace { .. } => Some("grace"),
|
Self::Grace { .. } => Some("grace"),
|
||||||
Self::NoStore => Some("store"),
|
Self::NoStore | Self::AllowStore => Some("store"),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,6 +247,9 @@ pub struct Rule {
|
|||||||
pub actions: Vec<RuleAction>,
|
pub actions: Vec<RuleAction>,
|
||||||
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
pub stop: bool,
|
pub stop: bool,
|
||||||
|
/// Imported vcl_hash actions run after vcl_recv (even after return(hash)).
|
||||||
|
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
|
||||||
|
pub hash_stage: bool,
|
||||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||||
pub vhosts: Vec<String>,
|
pub vhosts: Vec<String>,
|
||||||
}
|
}
|
||||||
@@ -365,6 +409,7 @@ pub struct CompiledRule {
|
|||||||
conditions: Vec<CompiledCondition>,
|
conditions: Vec<CompiledCondition>,
|
||||||
actions: Vec<RuleAction>,
|
actions: Vec<RuleAction>,
|
||||||
stop: bool,
|
stop: bool,
|
||||||
|
hash_stage: bool,
|
||||||
counter: Arc<AtomicU64>,
|
counter: Arc<AtomicU64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -516,6 +561,16 @@ fn compile_condition(condition: &RuleCondition, stage: RuleStage) -> Result<Comp
|
|||||||
|
|
||||||
fn validate_action(action: &RuleAction) -> Result<()> {
|
fn validate_action(action: &RuleAction) -> Result<()> {
|
||||||
match action {
|
match action {
|
||||||
|
RuleAction::SetRequestHeader { name, value } => {
|
||||||
|
request_rule_header_name(name)?;
|
||||||
|
ensure!(
|
||||||
|
value.len() <= 1024 && HeaderValue::from_str(value).is_ok(),
|
||||||
|
"invalid request header value"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
RuleAction::RemoveRequestHeader { name } => {
|
||||||
|
request_rule_header_name(name)?;
|
||||||
|
}
|
||||||
RuleAction::StripCookies { keep } => {
|
RuleAction::StripCookies { keep } => {
|
||||||
ensure!(keep.len() <= MAX_RULE_VALUES, "too many cookie names");
|
ensure!(keep.len() <= MAX_RULE_VALUES, "too many cookie names");
|
||||||
ensure!(
|
ensure!(
|
||||||
@@ -537,8 +592,8 @@ fn validate_action(action: &RuleAction) -> Result<()> {
|
|||||||
RuleAction::HashHeader { name } => {
|
RuleAction::HashHeader { name } => {
|
||||||
let header = rule_header_name(name)?;
|
let header = rule_header_name(name)?;
|
||||||
ensure!(
|
ensure!(
|
||||||
header != http::header::COOKIE && header != http::header::AUTHORIZATION,
|
header != http::header::AUTHORIZATION,
|
||||||
"use hash cookie instead of hashing the whole Cookie or Authorization header"
|
"Authorization cannot be added to a shared cache key"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
RuleAction::HashCookie { name } => ensure!(valid_cookie_name(name), "invalid cookie name"),
|
RuleAction::HashCookie { name } => ensure!(valid_cookie_name(name), "invalid cookie name"),
|
||||||
@@ -548,7 +603,9 @@ fn validate_action(action: &RuleAction) -> Result<()> {
|
|||||||
"TTL and grace are limited to one year"
|
"TTL and grace are limited to one year"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
RuleAction::SetHeader { name, value } | RuleAction::DefaultHeader { name, value } => {
|
RuleAction::SetBackendHeader { name, value }
|
||||||
|
| RuleAction::SetHeader { name, value }
|
||||||
|
| RuleAction::DefaultHeader { name, value } => {
|
||||||
let header = rule_header_name(name)?;
|
let header = rule_header_name(name)?;
|
||||||
ensure!(
|
ensure!(
|
||||||
!PROTECTED_RULE_HEADERS.contains(&header.as_str()),
|
!PROTECTED_RULE_HEADERS.contains(&header.as_str()),
|
||||||
@@ -559,7 +616,7 @@ fn validate_action(action: &RuleAction) -> Result<()> {
|
|||||||
"invalid header value"
|
"invalid header value"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
RuleAction::RemoveHeader { name } => {
|
RuleAction::RemoveBackendHeader { name } | RuleAction::RemoveHeader { name } => {
|
||||||
let header = rule_header_name(name)?;
|
let header = rule_header_name(name)?;
|
||||||
ensure!(
|
ensure!(
|
||||||
!PROTECTED_RULE_HEADERS.contains(&header.as_str()),
|
!PROTECTED_RULE_HEADERS.contains(&header.as_str()),
|
||||||
@@ -567,7 +624,9 @@ fn validate_action(action: &RuleAction) -> Result<()> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
RuleAction::Pass
|
RuleAction::Pass
|
||||||
|
| RuleAction::Lookup
|
||||||
| RuleAction::NoStore
|
| RuleAction::NoStore
|
||||||
|
| RuleAction::AllowStore
|
||||||
| RuleAction::IgnoreCacheControl
|
| RuleAction::IgnoreCacheControl
|
||||||
| RuleAction::StripSetCookie => {}
|
| RuleAction::StripSetCookie => {}
|
||||||
}
|
}
|
||||||
@@ -617,8 +676,13 @@ fn compile_rule(rule: &Rule, origin: RuleOrigin, scope: &str) -> Result<Compiled
|
|||||||
rule.id
|
rule.id
|
||||||
);
|
);
|
||||||
ensure!(
|
ensure!(
|
||||||
!rule.actions.is_empty() && rule.actions.len() <= MAX_RULE_ACTIONS,
|
(!rule.actions.is_empty() || rule.stop) && rule.actions.len() <= MAX_RULE_ACTIONS,
|
||||||
"cache rule {} needs 1-{MAX_RULE_ACTIONS} actions",
|
"cache rule {} needs 1-{MAX_RULE_ACTIONS} actions, or a terminal return",
|
||||||
|
rule.id
|
||||||
|
);
|
||||||
|
ensure!(
|
||||||
|
!rule.hash_stage || rule.stage == RuleStage::Request,
|
||||||
|
"cache rule {}: hash_stage requires the request stage",
|
||||||
rule.id
|
rule.id
|
||||||
);
|
);
|
||||||
for action in &rule.actions {
|
for action in &rule.actions {
|
||||||
@@ -646,6 +710,7 @@ fn compile_rule(rule: &Rule, origin: RuleOrigin, scope: &str) -> Result<Compiled
|
|||||||
conditions,
|
conditions,
|
||||||
actions: rule.actions.clone(),
|
actions: rule.actions.clone(),
|
||||||
stop: rule.stop,
|
stop: rule.stop,
|
||||||
|
hash_stage: rule.hash_stage,
|
||||||
counter: rule_counter(origin, scope, &rule.id),
|
counter: rule_counter(origin, scope, &rule.id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -653,6 +718,7 @@ fn compile_rule(rule: &Rule, origin: RuleOrigin, scope: &str) -> Result<Compiled
|
|||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct CompiledRules {
|
pub struct CompiledRules {
|
||||||
request: Vec<CompiledRule>,
|
request: Vec<CompiledRule>,
|
||||||
|
hash: Vec<CompiledRule>,
|
||||||
response: Vec<CompiledRule>,
|
response: Vec<CompiledRule>,
|
||||||
deliver: Vec<CompiledRule>,
|
deliver: Vec<CompiledRule>,
|
||||||
}
|
}
|
||||||
@@ -682,6 +748,7 @@ impl CompiledRules {
|
|||||||
}
|
}
|
||||||
let item = compile_rule(rule, origin, vhost_id)?;
|
let item = compile_rule(rule, origin, vhost_id)?;
|
||||||
match item.stage {
|
match item.stage {
|
||||||
|
RuleStage::Request if item.hash_stage => compiled.hash.push(item),
|
||||||
RuleStage::Request => compiled.request.push(item),
|
RuleStage::Request => compiled.request.push(item),
|
||||||
RuleStage::Response => compiled.response.push(item),
|
RuleStage::Response => compiled.response.push(item),
|
||||||
RuleStage::Deliver => compiled.deliver.push(item),
|
RuleStage::Deliver => compiled.deliver.push(item),
|
||||||
@@ -690,7 +757,8 @@ impl CompiledRules {
|
|||||||
Ok(compiled)
|
Ok(compiled)
|
||||||
}
|
}
|
||||||
pub fn is_empty(&self) -> bool {
|
pub fn is_empty(&self) -> bool {
|
||||||
self.request.is_empty() && self.response.is_empty() && self.deliver.is_empty()
|
self.request.is_empty() && self.hash.is_empty()
|
||||||
|
&& self.response.is_empty() && self.deliver.is_empty()
|
||||||
}
|
}
|
||||||
pub fn has_deliver_rules(&self) -> bool {
|
pub fn has_deliver_rules(&self) -> bool {
|
||||||
!self.deliver.is_empty()
|
!self.deliver.is_empty()
|
||||||
@@ -871,6 +939,10 @@ pub struct RuleOverride {
|
|||||||
#[derive(Debug, Clone, Default, Serialize)]
|
#[derive(Debug, Clone, Default, Serialize)]
|
||||||
pub struct RequestRuleOutcome {
|
pub struct RequestRuleOutcome {
|
||||||
pub pass: Option<String>,
|
pub pass: Option<String>,
|
||||||
|
pub lookup: Option<String>,
|
||||||
|
/// Ordered, validated edits applied to the forwarded request as well as
|
||||||
|
/// to the rule evaluation copy.
|
||||||
|
pub header_edits: Vec<BackendHeaderEdit>,
|
||||||
pub strip_cookies: Option<Vec<String>>,
|
pub strip_cookies: Option<Vec<String>>,
|
||||||
pub query_edits: Vec<(Vec<String>, bool)>,
|
pub query_edits: Vec<(Vec<String>, bool)>,
|
||||||
pub hash: Vec<String>,
|
pub hash: Vec<String>,
|
||||||
@@ -878,6 +950,13 @@ pub struct RequestRuleOutcome {
|
|||||||
pub overridden: Vec<RuleOverride>,
|
pub overridden: Vec<RuleOverride>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, PartialEq, Eq)]
|
||||||
|
#[serde(tag = "type", rename_all = "snake_case")]
|
||||||
|
pub enum BackendHeaderEdit {
|
||||||
|
Set { name: String, value: String },
|
||||||
|
Remove { name: String },
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize, PartialEq, Eq)]
|
#[derive(Debug, Clone, Default, Serialize, PartialEq, Eq)]
|
||||||
pub struct ResponseOverrides {
|
pub struct ResponseOverrides {
|
||||||
pub ttl: Option<u64>,
|
pub ttl: Option<u64>,
|
||||||
@@ -885,6 +964,8 @@ pub struct ResponseOverrides {
|
|||||||
pub no_store: bool,
|
pub no_store: bool,
|
||||||
pub ignore_cache_control: bool,
|
pub ignore_cache_control: bool,
|
||||||
pub strip_set_cookie: bool,
|
pub strip_set_cookie: bool,
|
||||||
|
/// Ordered backend header mutations. Global rules cannot replace vhost edits.
|
||||||
|
pub header_edits: Vec<BackendHeaderEdit>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ResponseOverrides {
|
impl ResponseOverrides {
|
||||||
@@ -894,10 +975,31 @@ impl ResponseOverrides {
|
|||||||
no_store: false,
|
no_store: false,
|
||||||
ignore_cache_control: false,
|
ignore_cache_control: false,
|
||||||
strip_set_cookie: false,
|
strip_set_cookie: false,
|
||||||
|
header_edits: Vec::new(),
|
||||||
};
|
};
|
||||||
pub fn is_none(&self) -> bool {
|
pub fn is_none(&self) -> bool {
|
||||||
*self == Self::NONE
|
*self == Self::NONE
|
||||||
}
|
}
|
||||||
|
pub fn apply_headers(&self, headers: &mut HeaderMap) {
|
||||||
|
for edit in &self.header_edits {
|
||||||
|
match edit {
|
||||||
|
BackendHeaderEdit::Set { name, value } => {
|
||||||
|
if let (Ok(header), Ok(value)) = (
|
||||||
|
http::HeaderName::from_bytes(name.as_bytes()),
|
||||||
|
HeaderValue::from_str(value),
|
||||||
|
) {
|
||||||
|
headers.insert(header, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BackendHeaderEdit::Remove { name } => {
|
||||||
|
headers.remove(name.as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if self.strip_set_cookie {
|
||||||
|
headers.remove(http::header::SET_COOKIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Default, Serialize)]
|
#[derive(Debug, Clone, Default, Serialize)]
|
||||||
@@ -913,6 +1015,8 @@ pub struct DeliverRuleOutcome {
|
|||||||
pub defaults: Vec<(String, String)>,
|
pub defaults: Vec<(String, String)>,
|
||||||
pub remove: Vec<String>,
|
pub remove: Vec<String>,
|
||||||
pub matched: Vec<RuleMatchInfo>,
|
pub matched: Vec<RuleMatchInfo>,
|
||||||
|
#[serde(skip)]
|
||||||
|
edits: Vec<(u8, String, String)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn info(rule: &CompiledRule) -> RuleMatchInfo {
|
fn info(rule: &CompiledRule) -> RuleMatchInfo {
|
||||||
@@ -939,17 +1043,17 @@ fn claim(
|
|||||||
rule.id
|
rule.id
|
||||||
);
|
);
|
||||||
match owners.get(aspect) {
|
match owners.get(aspect) {
|
||||||
Some(winner) => {
|
Some(winner) if winner.starts_with("vhost:") && rule.origin == RuleOrigin::Global => {
|
||||||
if winner != &label {
|
|
||||||
overridden.push(RuleOverride {
|
overridden.push(RuleOverride {
|
||||||
aspect,
|
aspect,
|
||||||
winner: winner.clone(),
|
winner: winner.clone(),
|
||||||
ignored: label,
|
ignored: label,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
None => {
|
_ => {
|
||||||
|
// Last matching assignment wins within the same scope; vhost
|
||||||
|
// priority is preserved over later global rules.
|
||||||
owners.insert(aspect, label);
|
owners.insert(aspect, label);
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@@ -960,8 +1064,16 @@ impl CompiledRules {
|
|||||||
pub fn evaluate_request(&self, request: &RuleRequest, count: bool) -> RequestRuleOutcome {
|
pub fn evaluate_request(&self, request: &RuleRequest, count: bool) -> RequestRuleOutcome {
|
||||||
let mut outcome = RequestRuleOutcome::default();
|
let mut outcome = RequestRuleOutcome::default();
|
||||||
let mut owners = HashMap::new();
|
let mut owners = HashMap::new();
|
||||||
for rule in &self.request {
|
let mut header_owners: HashMap<String, RuleOrigin> = HashMap::new();
|
||||||
if !rule.matches(request, None) {
|
let mut current = request.clone();
|
||||||
|
// In Varnish, vcl_hash runs after vcl_recv's return(hash), not as
|
||||||
|
// ordinary statements after it. Preserve that ordering in imported VCL.
|
||||||
|
for (is_hash_stage, rules) in [(false, &self.request), (true, &self.hash)] {
|
||||||
|
if is_hash_stage && outcome.pass.is_some() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for rule in rules.iter() {
|
||||||
|
if !rule.matches(¤t, None) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if count {
|
if count {
|
||||||
@@ -975,36 +1087,66 @@ impl CompiledRules {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
match action {
|
match action {
|
||||||
RuleAction::Pass => outcome.pass = Some(rule.id.clone()),
|
RuleAction::Pass => {
|
||||||
RuleAction::StripCookies { keep } => match &mut outcome.strip_cookies {
|
outcome.pass = Some(rule.id.clone());
|
||||||
|
outcome.lookup = None;
|
||||||
|
}
|
||||||
|
RuleAction::Lookup => {
|
||||||
|
outcome.lookup = Some(rule.id.clone());
|
||||||
|
outcome.pass = None;
|
||||||
|
},
|
||||||
|
RuleAction::SetRequestHeader { name, value } => {
|
||||||
|
let key = name.to_ascii_lowercase();
|
||||||
|
if header_owners.get(&key) == Some(&RuleOrigin::Vhost)
|
||||||
|
&& rule.origin != RuleOrigin::Vhost
|
||||||
|
{ continue; }
|
||||||
|
header_owners.insert(key.clone(), rule.origin);
|
||||||
|
let header = http::HeaderName::from_bytes(key.as_bytes())
|
||||||
|
.expect("validated request header");
|
||||||
|
let value_header = HeaderValue::from_str(value)
|
||||||
|
.expect("validated request header value");
|
||||||
|
current.headers.insert(header, value_header);
|
||||||
|
outcome.header_edits.push(BackendHeaderEdit::Set {
|
||||||
|
name: key, value: value.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
RuleAction::RemoveRequestHeader { name } => {
|
||||||
|
let key = name.to_ascii_lowercase();
|
||||||
|
if header_owners.get(&key) == Some(&RuleOrigin::Vhost)
|
||||||
|
&& rule.origin != RuleOrigin::Vhost
|
||||||
|
{ continue; }
|
||||||
|
header_owners.insert(key.clone(), rule.origin);
|
||||||
|
current.headers.remove(key.as_str());
|
||||||
|
outcome.header_edits.push(BackendHeaderEdit::Remove { name: key });
|
||||||
|
}
|
||||||
|
RuleAction::StripCookies { keep } => {
|
||||||
|
match &mut outcome.strip_cookies {
|
||||||
Some(existing) => existing.retain(|name| keep.contains(name)),
|
Some(existing) => existing.retain(|name| keep.contains(name)),
|
||||||
None => outcome.strip_cookies = Some(keep.clone()),
|
None => outcome.strip_cookies = Some(keep.clone()),
|
||||||
},
|
}
|
||||||
|
outcome.rewrite_cookies(&mut current.headers);
|
||||||
|
}
|
||||||
RuleAction::StripQuery { params, keep_only } => {
|
RuleAction::StripQuery { params, keep_only } => {
|
||||||
outcome.query_edits.push((params.clone(), *keep_only))
|
outcome.query_edits.push((params.clone(), *keep_only));
|
||||||
|
if let Some(rewritten) = outcome.rewrite_query(current.query.as_deref()) {
|
||||||
|
current.query = rewritten;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
RuleAction::HashHeader { name } => {
|
RuleAction::HashHeader { name } => {
|
||||||
let value = rule_header_name(name)
|
let value = rule_header_name(name)
|
||||||
.ok()
|
.ok()
|
||||||
.map(|header| {
|
.map(|header| {
|
||||||
request
|
current.headers.get_all(&header).iter()
|
||||||
.headers
|
|
||||||
.get_all(&header)
|
|
||||||
.iter()
|
|
||||||
.filter_map(|v| v.to_str().ok())
|
.filter_map(|v| v.to_str().ok())
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>().join(",")
|
||||||
.join(",")
|
|
||||||
})
|
})
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
outcome
|
outcome.hash.push(format!("h:{}={value}", name.to_ascii_lowercase()));
|
||||||
.hash
|
|
||||||
.push(format!("h:{}={value}", name.to_ascii_lowercase()));
|
|
||||||
}
|
}
|
||||||
RuleAction::HashCookie { name } => {
|
RuleAction::HashCookie { name } => {
|
||||||
let value = cookie_values(&request.headers)
|
let value = cookie_values(¤t.headers)
|
||||||
.find(|(key, _)| key == name)
|
.find(|(key, _)| key == name)
|
||||||
.map(|(_, value)| value)
|
.map(|(_, value)| value).unwrap_or("");
|
||||||
.unwrap_or("");
|
|
||||||
outcome.hash.push(format!("c:{name}={value}"));
|
outcome.hash.push(format!("c:{name}={value}"));
|
||||||
}
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
@@ -1014,6 +1156,7 @@ impl CompiledRules {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
outcome
|
outcome
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1026,8 +1169,10 @@ impl CompiledRules {
|
|||||||
) -> ResponseRuleOutcome {
|
) -> ResponseRuleOutcome {
|
||||||
let mut outcome = ResponseRuleOutcome::default();
|
let mut outcome = ResponseRuleOutcome::default();
|
||||||
let mut owners = HashMap::new();
|
let mut owners = HashMap::new();
|
||||||
|
let mut header_owners: HashMap<String, RuleOrigin> = HashMap::new();
|
||||||
|
let mut current = headers.clone();
|
||||||
for rule in &self.response {
|
for rule in &self.response {
|
||||||
if !rule.matches(request, Some((status, headers))) {
|
if !rule.matches(request, Some((status, ¤t))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if count {
|
if count {
|
||||||
@@ -1044,8 +1189,41 @@ impl CompiledRules {
|
|||||||
RuleAction::Ttl { seconds } => outcome.overrides.ttl = Some(*seconds),
|
RuleAction::Ttl { seconds } => outcome.overrides.ttl = Some(*seconds),
|
||||||
RuleAction::Grace { seconds } => outcome.overrides.grace = Some(*seconds),
|
RuleAction::Grace { seconds } => outcome.overrides.grace = Some(*seconds),
|
||||||
RuleAction::NoStore => outcome.overrides.no_store = true,
|
RuleAction::NoStore => outcome.overrides.no_store = true,
|
||||||
|
RuleAction::AllowStore => outcome.overrides.no_store = false,
|
||||||
RuleAction::IgnoreCacheControl => outcome.overrides.ignore_cache_control = true,
|
RuleAction::IgnoreCacheControl => outcome.overrides.ignore_cache_control = true,
|
||||||
RuleAction::StripSetCookie => outcome.overrides.strip_set_cookie = true,
|
RuleAction::StripSetCookie => {
|
||||||
|
if header_owners.get("set-cookie") != Some(&RuleOrigin::Vhost)
|
||||||
|
|| rule.origin == RuleOrigin::Vhost
|
||||||
|
{
|
||||||
|
header_owners.insert("set-cookie".into(), rule.origin);
|
||||||
|
outcome.overrides.strip_set_cookie = true;
|
||||||
|
current.remove(http::header::SET_COOKIE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RuleAction::SetBackendHeader { name, value } => {
|
||||||
|
let key = name.to_ascii_lowercase();
|
||||||
|
if header_owners.get(&key) == Some(&RuleOrigin::Vhost)
|
||||||
|
&& rule.origin != RuleOrigin::Vhost
|
||||||
|
{ continue; }
|
||||||
|
header_owners.insert(key.clone(), rule.origin);
|
||||||
|
if let (Ok(header), Ok(value_header)) = (
|
||||||
|
http::HeaderName::from_bytes(key.as_bytes()), HeaderValue::from_str(value)
|
||||||
|
) {
|
||||||
|
current.insert(header, value_header);
|
||||||
|
outcome.overrides.header_edits.push(BackendHeaderEdit::Set {
|
||||||
|
name: key, value: value.clone(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RuleAction::RemoveBackendHeader { name } => {
|
||||||
|
let key = name.to_ascii_lowercase();
|
||||||
|
if header_owners.get(&key) == Some(&RuleOrigin::Vhost)
|
||||||
|
&& rule.origin != RuleOrigin::Vhost
|
||||||
|
{ continue; }
|
||||||
|
header_owners.insert(key.clone(), rule.origin);
|
||||||
|
current.remove(key.as_str());
|
||||||
|
outcome.overrides.header_edits.push(BackendHeaderEdit::Remove { name: key });
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1064,37 +1242,72 @@ impl CompiledRules {
|
|||||||
count: bool,
|
count: bool,
|
||||||
) -> DeliverRuleOutcome {
|
) -> DeliverRuleOutcome {
|
||||||
let mut outcome = DeliverRuleOutcome::default();
|
let mut outcome = DeliverRuleOutcome::default();
|
||||||
|
let mut ownership: HashMap<String, RuleOrigin> = HashMap::new();
|
||||||
|
let mut current = headers.clone();
|
||||||
for rule in &self.deliver {
|
for rule in &self.deliver {
|
||||||
if !rule.matches(request, Some((status, headers))) {
|
if !rule.matches(request, Some((status, ¤t))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if count {
|
if count { rule.counter.fetch_add(1, Ordering::Relaxed); }
|
||||||
rule.counter.fetch_add(1, Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
outcome.matched.push(info(rule));
|
outcome.matched.push(info(rule));
|
||||||
for action in &rule.actions {
|
for action in &rule.actions {
|
||||||
match action {
|
let (kind, name, value) = match action {
|
||||||
RuleAction::SetHeader { name, value } => {
|
RuleAction::SetHeader { name, value } => (1, name, value.as_str()),
|
||||||
outcome.set.push((name.to_ascii_lowercase(), value.clone()))
|
RuleAction::DefaultHeader { name, value } => (2, name, value.as_str()),
|
||||||
|
RuleAction::RemoveHeader { name } => (3, name, ""),
|
||||||
|
_ => continue,
|
||||||
|
};
|
||||||
|
let name = name.to_ascii_lowercase();
|
||||||
|
if ownership.get(&name) == Some(&RuleOrigin::Vhost)
|
||||||
|
&& rule.origin != RuleOrigin::Vhost
|
||||||
|
{ continue; }
|
||||||
|
// A default (set-if-missing) does not claim an existing header.
|
||||||
|
if kind == 2 && current.contains_key(name.as_str()) { continue; }
|
||||||
|
ownership.insert(name.clone(), rule.origin);
|
||||||
|
match kind {
|
||||||
|
1 => {
|
||||||
|
outcome.set.push((name.clone(), value.to_owned()));
|
||||||
|
current.insert(http::HeaderName::from_bytes(name.as_bytes()).expect("validated name"),
|
||||||
|
HeaderValue::from_str(value).expect("validated value"));
|
||||||
}
|
}
|
||||||
RuleAction::RemoveHeader { name } => {
|
2 => {
|
||||||
outcome.remove.push(name.to_ascii_lowercase())
|
outcome.defaults.push((name.clone(), value.to_owned()));
|
||||||
|
current.insert(http::HeaderName::from_bytes(name.as_bytes()).expect("validated name"),
|
||||||
|
HeaderValue::from_str(value).expect("validated value"));
|
||||||
}
|
}
|
||||||
RuleAction::DefaultHeader { name, value } => outcome
|
_ => {
|
||||||
.defaults
|
outcome.remove.push(name.clone());
|
||||||
.push((name.to_ascii_lowercase(), value.clone())),
|
current.remove(name.as_str());
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if rule.stop {
|
outcome.edits.push((kind, name, value.to_owned()));
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
if rule.stop { break; }
|
||||||
}
|
}
|
||||||
outcome
|
outcome
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl RequestRuleOutcome {
|
impl RequestRuleOutcome {
|
||||||
|
pub fn apply_headers(&self, headers: &mut HeaderMap) {
|
||||||
|
for edit in &self.header_edits {
|
||||||
|
match edit {
|
||||||
|
BackendHeaderEdit::Set { name, value } => {
|
||||||
|
// Names and values were validated when the rule was compiled.
|
||||||
|
if let (Ok(name), Ok(value)) = (
|
||||||
|
http::HeaderName::from_bytes(name.as_bytes()),
|
||||||
|
HeaderValue::from_str(value),
|
||||||
|
) {
|
||||||
|
headers.insert(name, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BackendHeaderEdit::Remove { name } => {
|
||||||
|
headers.remove(name.as_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn rewrite_cookies(&self, headers: &mut HeaderMap) {
|
pub fn rewrite_cookies(&self, headers: &mut HeaderMap) {
|
||||||
let Some(keep) = &self.strip_cookies else {
|
let Some(keep) = &self.strip_cookies else {
|
||||||
return;
|
return;
|
||||||
@@ -1151,31 +1364,27 @@ impl RequestRuleOutcome {
|
|||||||
|
|
||||||
impl DeliverRuleOutcome {
|
impl DeliverRuleOutcome {
|
||||||
pub fn apply(&self, headers: &mut HeaderMap) {
|
pub fn apply(&self, headers: &mut HeaderMap) {
|
||||||
for name in &self.remove {
|
for (kind, name, value) in &self.edits {
|
||||||
if let Ok(header) = http::HeaderName::from_bytes(name.as_bytes()) {
|
let Ok(header) = http::HeaderName::from_bytes(name.as_bytes()) else { continue; };
|
||||||
headers.remove(header);
|
match kind {
|
||||||
}
|
1 => {
|
||||||
}
|
if let Ok(value) = HeaderValue::from_str(value) {
|
||||||
for (name, value) in &self.set {
|
|
||||||
if let (Ok(header), Ok(value)) = (
|
|
||||||
http::HeaderName::from_bytes(name.as_bytes()),
|
|
||||||
HeaderValue::from_str(value),
|
|
||||||
) {
|
|
||||||
headers.insert(header, value);
|
headers.insert(header, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (name, value) in &self.defaults {
|
2 => {
|
||||||
if let (Ok(header), Ok(value)) = (
|
|
||||||
http::HeaderName::from_bytes(name.as_bytes()),
|
|
||||||
HeaderValue::from_str(value),
|
|
||||||
) {
|
|
||||||
if !headers.contains_key(&header) {
|
if !headers.contains_key(&header) {
|
||||||
|
if let Ok(value) = HeaderValue::from_str(value) {
|
||||||
headers.insert(header, value);
|
headers.insert(header, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => { headers.remove(header); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct RuleContext {
|
pub struct RuleContext {
|
||||||
|
|||||||
Vendored
+376
@@ -346,6 +346,8 @@ sub vcl_deliver {
|
|||||||
.find(|rule| rule.actions.contains(&RuleAction::Ttl { seconds: 3600 }))
|
.find(|rule| rule.actions.contains(&RuleAction::Ttl { seconds: 3600 }))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert!(else_rule.conditions[0].negate);
|
assert!(else_rule.conditions[0].negate);
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("regsuball(req.url")));
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("empty values")));
|
||||||
assert!(imported
|
assert!(imported
|
||||||
.warnings
|
.warnings
|
||||||
.iter()
|
.iter()
|
||||||
@@ -357,4 +359,378 @@ sub vcl_deliver {
|
|||||||
assert!(import_vcl("sub vcl_recv { if (").is_err());
|
assert!(import_vcl("sub vcl_recv { if (").is_err());
|
||||||
assert!(import_vcl("vcl 4.1;").is_err());
|
assert!(import_vcl("vcl 4.1;").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn imported_vcl_cookie_pass_and_hash_stages_obey_terminal_returns() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
vcl 4.1;
|
||||||
|
sub vcl_recv {
|
||||||
|
if (req.http.Cookie ~ "sid=") { return(pass); }
|
||||||
|
if (req.http.Cookie) { return(hash); }
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
sub vcl_hash { hash_data(req.http.Cookie); }
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let session = request("/home", None, &[("cookie", "sid=123; lang=pl")]);
|
||||||
|
let session_out = compiled.evaluate_request(&session, false);
|
||||||
|
assert!(session_out.pass.is_some());
|
||||||
|
assert!(session_out.lookup.is_none());
|
||||||
|
assert!(session_out.hash.is_empty(), "vcl_hash cannot run after pass");
|
||||||
|
let language = request("/home", None, &[("cookie", "lang=pl")]);
|
||||||
|
let out = compiled.evaluate_request(&language, false);
|
||||||
|
assert!(out.pass.is_none());
|
||||||
|
assert!(out.lookup.is_some());
|
||||||
|
assert_eq!(out.hash_variant(), "h:cookie=lang=pl");
|
||||||
|
let mut compatible = Settings::default();
|
||||||
|
assert_eq!(
|
||||||
|
request_policy_with_vcl_cookie(&Method::GET, &language.headers, true, "/home", false, &compatible, true),
|
||||||
|
RequestPolicy::Use
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
request_policy(&Method::GET, &language.headers, true, "/home", false, &compatible),
|
||||||
|
RequestPolicy::Bypass("request_cookie")
|
||||||
|
);
|
||||||
|
compatible.varnish_compatible = false;
|
||||||
|
assert_eq!(
|
||||||
|
request_policy_with_vcl_cookie(&Method::GET, &language.headers, true, "/home", false, &compatible, true),
|
||||||
|
RequestPolicy::Bypass("request_cookie")
|
||||||
|
);
|
||||||
|
let with_authorization = request("/home", None, &[("cookie", "lang=pl"), ("authorization", "Basic user")]);
|
||||||
|
compatible.varnish_compatible = true;
|
||||||
|
assert_eq!(
|
||||||
|
request_policy_with_vcl_cookie(&Method::GET, &with_authorization.headers, true, "/home", false, &compatible, true),
|
||||||
|
RequestPolicy::Bypass("request_authorization")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn imported_vcl_nested_elsif_else_and_earlier_cookie_unset_are_visible() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
if (req.url ~ "^/static") {
|
||||||
|
unset req.http.Cookie;
|
||||||
|
if (req.http.Cookie) { return(pass); }
|
||||||
|
else { return(hash); }
|
||||||
|
} elsif (req.url ~ "^/private") { return(pass); }
|
||||||
|
else { return(hash); }
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let asset = request("/static/index.html", None, &[("cookie", "lang=pl; sid=7")]);
|
||||||
|
let matched = compiled.evaluate_request(&asset, false);
|
||||||
|
assert!(matched.lookup.is_some());
|
||||||
|
assert!(matched.pass.is_none());
|
||||||
|
let mut headers = asset.headers.clone();
|
||||||
|
matched.rewrite_cookies(&mut headers);
|
||||||
|
assert!(!headers.contains_key("cookie"));
|
||||||
|
assert!(compiled.evaluate_request(&request("/private/a", None, &[]), false).pass.is_some());
|
||||||
|
assert!(compiled.evaluate_request(&request("/other", None, &[]), false).lookup.is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn imported_backend_header_edits_change_policy_before_cache_admission() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_backend_response {
|
||||||
|
unset beresp.http.Cache-Control;
|
||||||
|
set beresp.http.Cache-Control = "public, max-age=77";
|
||||||
|
if (beresp.http.Cache-Control == "public, max-age=77") {
|
||||||
|
set beresp.ttl = 88s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let mut response = HeaderMap::new();
|
||||||
|
response.insert("cache-control", HeaderValue::from_static("private, no-store"));
|
||||||
|
let out = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false);
|
||||||
|
assert_eq!(out.overrides.ttl, Some(88));
|
||||||
|
out.overrides.apply_headers(&mut response);
|
||||||
|
assert_eq!(response["cache-control"], "public, max-age=77");
|
||||||
|
let strict = Settings {varnish_compatible: false, ..Default::default()};
|
||||||
|
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &out.overrides).is_some());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vhost_backend_header_wins_and_subsequent_rule_sees_mutation() {
|
||||||
|
let local = vec![
|
||||||
|
rule(serde_json::json!({"id":"local", "stage":"response", "actions":[{"type":"set_backend_header","name":"Cache-Control","value":"public, max-age=120"}]})),
|
||||||
|
rule(serde_json::json!({"id":"local-second", "stage":"response", "conditions":[{"field":"response_header","name":"Cache-Control","operator":"equals","values":["public, max-age=120"]}], "actions":[{"type":"ttl","seconds":125}]})),
|
||||||
|
];
|
||||||
|
let global = vec![rule(serde_json::json!({"id":"global", "stage":"response", "actions":[{"type":"remove_backend_header","name":"Cache-Control"}, {"type":"ttl","seconds":5}]}))];
|
||||||
|
let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap();
|
||||||
|
let original = HeaderMap::new();
|
||||||
|
let outcome = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &original, false);
|
||||||
|
let mut rewritten = original;
|
||||||
|
outcome.overrides.apply_headers(&mut rewritten);
|
||||||
|
assert_eq!(rewritten["cache-control"], "public, max-age=120");
|
||||||
|
assert_eq!(outcome.overrides.ttl, Some(125));
|
||||||
|
assert!(outcome.overridden.iter().any(|entry| entry.ignored == "global:global"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vhost_delivery_mutations_remain_ordered_and_global_cannot_unset() {
|
||||||
|
let local = vec![
|
||||||
|
rule(serde_json::json!({"id":"first", "stage":"deliver", "actions":[{"type":"set_header","name":"X-Decision","value":"first"}]})),
|
||||||
|
rule(serde_json::json!({"id":"second", "stage":"deliver", "conditions":[{"field":"response_header","name":"X-Decision","operator":"equals","values":["first"]}], "actions":[{"type":"remove_header","name":"X-Decision"}, {"type":"default_header","name":"X-Decision","value":"second"}]})),
|
||||||
|
];
|
||||||
|
let global = vec![rule(serde_json::json!({"id":"global", "stage":"deliver", "actions":[{"type":"remove_header","name":"X-Decision"}]}))];
|
||||||
|
let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap();
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
let outcome = compiled.evaluate_deliver(&request("/", None, &[]), StatusCode::OK, &headers, false);
|
||||||
|
outcome.apply(&mut headers);
|
||||||
|
assert_eq!(headers["x-decision"], "second");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn imported_terminal_deliver_does_not_run_following_rules() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_deliver {
|
||||||
|
if (req.url ~ "^/private") { return(deliver); }
|
||||||
|
set resp.http.X-Later = "yes";
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let mut response = HeaderMap::new();
|
||||||
|
compiled.evaluate_deliver(&request("/private", None, &[]), StatusCode::OK, &response, false).apply(&mut response);
|
||||||
|
assert!(!response.contains_key("x-later"));
|
||||||
|
compiled.evaluate_deliver(&request("/public", None, &[]), StatusCode::OK, &response, false).apply(&mut response);
|
||||||
|
assert_eq!(response["x-later"], "yes");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vcl_request_header_edits_are_visible_to_later_guards_hash_and_origin() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
set req.http.X-Device = "mobile";
|
||||||
|
if (req.http.X-Device == "mobile") {
|
||||||
|
unset req.http.X-Tracking;
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sub vcl_hash { hash_data(req.http.X-Device); }
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let original = request("/catalog", None, &[("x-tracking", "secret"), ("cookie", "lang=pl")]);
|
||||||
|
let outcome = compiled.evaluate_request(&original, false);
|
||||||
|
assert!(outcome.pass.is_none());
|
||||||
|
assert!(outcome.lookup.is_some());
|
||||||
|
assert_eq!(outcome.hash_variant(), "h:x-device=mobile");
|
||||||
|
assert_eq!(original.headers.get("x-tracking").unwrap(), "secret");
|
||||||
|
let mut forwarded = original.headers.clone();
|
||||||
|
outcome.apply_headers(&mut forwarded);
|
||||||
|
outcome.rewrite_cookies(&mut forwarded);
|
||||||
|
assert_eq!(forwarded["x-device"], "mobile");
|
||||||
|
assert!(!forwarded.contains_key("x-tracking"));
|
||||||
|
assert_eq!(forwarded["cookie"], "lang=pl");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn request_header_overrides_respect_vhost_priority_but_allow_other_globals() {
|
||||||
|
let local = vec![rule(serde_json::json!({
|
||||||
|
"id": "local-header", "actions": [{"type":"set_request_header", "name":"X-Device", "value":"local"}]
|
||||||
|
}))];
|
||||||
|
let global = vec![
|
||||||
|
rule(serde_json::json!({
|
||||||
|
"id": "global-header", "actions": [
|
||||||
|
{"type":"set_request_header", "name":"X-Device", "value":"global"},
|
||||||
|
{"type":"set_request_header", "name":"X-Public-View", "value":"yes"}
|
||||||
|
]
|
||||||
|
})),
|
||||||
|
rule(serde_json::json!({
|
||||||
|
"id": "global-match", "conditions": [{"field":"header", "name":"X-Device", "operator":"equals", "values":["local"]}],
|
||||||
|
"actions": [{"type":"hash_header", "name":"X-Public-View"}]
|
||||||
|
})),
|
||||||
|
];
|
||||||
|
let compiled = CompiledRules::compile("shop", &local, &global, false).unwrap();
|
||||||
|
let outcome = compiled.evaluate_request(&request("/", None, &[]), false);
|
||||||
|
let mut forwarded = HeaderMap::new();
|
||||||
|
outcome.apply_headers(&mut forwarded);
|
||||||
|
assert_eq!(forwarded["x-device"], "local");
|
||||||
|
assert_eq!(forwarded["x-public-view"], "yes");
|
||||||
|
assert_eq!(outcome.hash_variant(), "h:x-public-view=yes");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unsafe_request_edits_are_rejected_without_discarding_valid_neighbors() {
|
||||||
|
for name in ["Authorization", "Cookie", "Cache-Control", "X-Forwarded-For", "If-None-Match", "Host", "Content-Length"] {
|
||||||
|
let rules = vec![rule(serde_json::json!({
|
||||||
|
"id": "unsafe", "actions": [{"type":"remove_request_header", "name":name}]
|
||||||
|
}))];
|
||||||
|
assert!(validate_rules(&rules, true).is_err(), "must protect {name}");
|
||||||
|
}
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
set req.http.X-Safe = "one";
|
||||||
|
unset req.http.Authorization;
|
||||||
|
set req.http.X-Safe = "two";
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert_eq!(imported.warnings.len(), 1, "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let outcome = compiled.evaluate_request(&request("/", None, &[("authorization", "Bearer x")]), false);
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
headers.insert("authorization", HeaderValue::from_static("Bearer x"));
|
||||||
|
outcome.apply_headers(&mut headers);
|
||||||
|
assert_eq!(headers["x-safe"], "two");
|
||||||
|
assert_eq!(headers["authorization"], "Bearer x");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn uncacheable_false_reverses_only_previous_rule_no_store() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_backend_response {
|
||||||
|
set beresp.uncacheable = true;
|
||||||
|
set beresp.uncacheable = false;
|
||||||
|
set beresp.ttl = 60s;
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let compiled = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let mut response = HeaderMap::new();
|
||||||
|
response.insert("cache-control", HeaderValue::from_static("max-age=30"));
|
||||||
|
let outcome = compiled.evaluate_response(&request("/", None, &[]), StatusCode::OK, &response, false);
|
||||||
|
assert!(!outcome.overrides.no_store);
|
||||||
|
assert_eq!(outcome.overrides.ttl, Some(60));
|
||||||
|
let strict = Settings { varnish_compatible: false, ..Default::default() };
|
||||||
|
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_some());
|
||||||
|
response.insert("cache-control", HeaderValue::from_static("private, no-store"));
|
||||||
|
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_none());
|
||||||
|
response.remove("cache-control");
|
||||||
|
response.insert("set-cookie", HeaderValue::from_static("sid=1"));
|
||||||
|
assert!(plan_with(StatusCode::OK, &response, &strict, std::time::Duration::ZERO, &outcome.overrides).is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vhost_allow_store_overrides_global_no_store() {
|
||||||
|
let local = vec![rule(serde_json::json!({"id":"local-store", "stage":"response", "actions":[{"type":"allow_store"}]}))];
|
||||||
|
let global = vec![rule(serde_json::json!({"id":"global-store", "stage":"response", "actions":[{"type":"no_store"}]}))];
|
||||||
|
let rules = CompiledRules::compile("shop", &local, &global, false).unwrap();
|
||||||
|
let outcome = rules.evaluate_response(&request("/", None, &[]), StatusCode::OK, &HeaderMap::new(), false);
|
||||||
|
assert!(!outcome.overrides.no_store);
|
||||||
|
assert!(outcome.overridden.iter().any(|entry| entry.aspect == "store" && entry.ignored == "global:global-store"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn unsupported_url_regex_is_warned_not_misconverted_to_query_removal() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
set req.url = regsub(req.url, "^/utm_foo", "/other");
|
||||||
|
set req.url = regsuball(req.url, "^/utm_foo", "\\1");
|
||||||
|
set req.url = regsuball(req.url, "(\\?|&)(utm_foo)=[^&]*", "deleted");
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.rules.is_empty(), "unsupported VCL must never strip unrelated query parameters");
|
||||||
|
assert_eq!(imported.warnings.len(), 3, "{:?}", imported.warnings);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn valid_vcl_import_flushes_long_action_blocks_instead_of_dropping_them() {
|
||||||
|
let mut source = String::from("sub vcl_recv {\n");
|
||||||
|
for id in 1..=20 { source.push_str(&format!("set req.http.X-Rule-{id} = \"ok\";\n")); }
|
||||||
|
source.push_str("}");
|
||||||
|
let imported = import_vcl(&source).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let outcome = rules.evaluate_request(&request("/", None, &[]), false);
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
outcome.apply_headers(&mut headers);
|
||||||
|
assert_eq!(headers["x-rule-1"], "ok");
|
||||||
|
assert_eq!(headers["x-rule-20"], "ok");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vcl_builtin_hash_fields_are_already_in_rustproxy_key() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
set req.http.X-Device = "mobile";
|
||||||
|
return(hash);
|
||||||
|
}
|
||||||
|
sub vcl_hash {
|
||||||
|
hash_data(req.url);
|
||||||
|
hash_data(req.http.Host);
|
||||||
|
hash_data(req.http.X-Device);
|
||||||
|
return(lookup);
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
validate_rules(&imported.rules, true).unwrap();
|
||||||
|
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let outcome = rules.evaluate_request(&request("/catalog", Some("lang=pl"), &[]), false);
|
||||||
|
assert!(outcome.lookup.is_some());
|
||||||
|
assert!(outcome.pass.is_none());
|
||||||
|
// The path, query and authority already form the base cache key.
|
||||||
|
assert_eq!(outcome.hash, vec!["h:x-device=mobile"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vcl_quoted_strings_support_escaped_quotes_and_backslashes() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
set req.http.X-Note = "quote: \" and slash: \\";
|
||||||
|
}
|
||||||
|
sub vcl_deliver {
|
||||||
|
set resp.http.X-Note = "a \"quote\" and a \\ slash";
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.is_empty(), "{:?}", imported.warnings);
|
||||||
|
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let mut headers = HeaderMap::new();
|
||||||
|
rules.evaluate_request(&request("/", None, &[]), false).apply_headers(&mut headers);
|
||||||
|
assert_eq!(headers["x-note"], "quote: \" and slash: \\");
|
||||||
|
let mut response_headers = HeaderMap::new();
|
||||||
|
rules.evaluate_deliver(&request("/", None, &[]), StatusCode::OK, &response_headers, false)
|
||||||
|
.apply(&mut response_headers);
|
||||||
|
assert_eq!(response_headers["x-note"], "a \"quote\" and a \\ slash");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn malformed_vcl_statements_are_warned_and_do_not_apply_partial_actions() {
|
||||||
|
let imported = import_vcl(r#"
|
||||||
|
sub vcl_recv {
|
||||||
|
return(hash, pass);
|
||||||
|
hash_data(req.http.X-Should-Not-Hash);
|
||||||
|
set req.http.X-Allowed = "yes";
|
||||||
|
}
|
||||||
|
sub vcl_hash {
|
||||||
|
hash_data(req.http.X-Extra, req.http.X-Another);
|
||||||
|
hash_data(req.http.X-Allowed);
|
||||||
|
}
|
||||||
|
sub vcl_backend_response {
|
||||||
|
set beresp.ttl = 90s + 20s;
|
||||||
|
unset beresp.http.Vary extra;
|
||||||
|
set beresp.ttl = 30s;
|
||||||
|
}
|
||||||
|
sub vcl_deliver {
|
||||||
|
set resp.http.X-Bad + "no";
|
||||||
|
unset resp.http.Vary extra;
|
||||||
|
unset resp.http.X-Trace;
|
||||||
|
}
|
||||||
|
"#).unwrap();
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("return requires")), "{:?}", imported.warnings);
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("hash_data is only supported inside")));
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("hash_data supports")));
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("set beresp requires")));
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("unset beresp requires")));
|
||||||
|
assert!(imported.warnings.iter().any(|warning| warning.contains("unset resp requires")));
|
||||||
|
validate_rules(&imported.rules, true).unwrap();
|
||||||
|
let rules = CompiledRules::compile("shop", &[], &imported.rules, false).unwrap();
|
||||||
|
let outcome = rules.evaluate_request(&request("/", None, &[]), false);
|
||||||
|
assert!(outcome.pass.is_none());
|
||||||
|
assert!(outcome.lookup.is_none());
|
||||||
|
assert_eq!(outcome.hash, vec!["h:x-allowed=yes"]);
|
||||||
|
let response = rules.evaluate_response(&request("/", None, &[]), StatusCode::OK, &HeaderMap::new(), false);
|
||||||
|
assert_eq!(response.overrides.ttl, Some(30));
|
||||||
|
assert!(response.overrides.header_edits.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn vcl_tokenizer_rejects_unclosed_quotes_and_comments() {
|
||||||
|
assert!(import_vcl("sub vcl_recv { set req.http.X-A = \"missing; }").is_err());
|
||||||
|
assert!(import_vcl("sub vcl_recv { /* missing */ set req.http.X-A = \"x\"; /*").is_err());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+38
-10
@@ -257,13 +257,11 @@ mod varnish_compatible_tests {
|
|||||||
assert_eq!(fallback_plan.ttl, 42);
|
assert_eq!(fallback_plan.ttl, 42);
|
||||||
assert!(!fallback_plan.requires_revalidation);
|
assert!(!fallback_plan.requires_revalidation);
|
||||||
let nonpublic_no_cache = headers("no-cache, max-age=60");
|
let nonpublic_no_cache = headers("no-cache, max-age=60");
|
||||||
assert!(plan(
|
let nonpublic_plan = plan(StatusCode::OK, &nonpublic_no_cache, &fallback, Duration::ZERO)
|
||||||
StatusCode::OK,
|
.expect("compatible fallback overrides no-cache without public");
|
||||||
&nonpublic_no_cache,
|
assert_eq!(nonpublic_plan.ttl, 42);
|
||||||
&fallback,
|
assert!(!nonpublic_plan.requires_revalidation);
|
||||||
Duration::ZERO
|
assert!(plan(StatusCode::OK, &nonpublic_no_cache, &strict, Duration::ZERO).is_none());
|
||||||
)
|
|
||||||
.is_none());
|
|
||||||
let mut surrogate = public_no_cache.clone();
|
let mut surrogate = public_no_cache.clone();
|
||||||
surrogate.insert(
|
surrogate.insert(
|
||||||
"surrogate-control",
|
"surrogate-control",
|
||||||
@@ -308,6 +306,36 @@ mod varnish_compatible_tests {
|
|||||||
assert!(plan(StatusCode::OK, &vary, &fallback, Duration::ZERO).is_none());
|
assert!(plan(StatusCode::OK, &vary, &fallback, Duration::ZERO).is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn compatibility_fallback_and_explicit_vcl_ttl_keep_strict_revalidation() {
|
||||||
|
let mut compatible = Settings::default();
|
||||||
|
compatible.default_ttl_seconds = 60;
|
||||||
|
let mut strict = compatible.clone();
|
||||||
|
strict.varnish_compatible = false;
|
||||||
|
let response = headers("no-cache");
|
||||||
|
assert_eq!(plan(StatusCode::OK, &response, &compatible, Duration::ZERO).unwrap().ttl, 60);
|
||||||
|
assert!(plan(StatusCode::OK, &response, &strict, Duration::ZERO).is_none());
|
||||||
|
|
||||||
|
compatible.default_ttl_seconds = 0;
|
||||||
|
let mut overrides = ResponseOverrides::NONE;
|
||||||
|
overrides.ttl = Some(25);
|
||||||
|
let custom = plan_with(StatusCode::OK, &response, &compatible, Duration::ZERO, &overrides)
|
||||||
|
.expect("explicit vcl ttl in compatibility mode overrides no-cache");
|
||||||
|
assert_eq!(custom.ttl, 25);
|
||||||
|
assert!(!custom.requires_revalidation);
|
||||||
|
assert!(plan_with(StatusCode::OK, &response, &strict, Duration::ZERO, &overrides).is_none());
|
||||||
|
|
||||||
|
let empty_headers = HeaderMap::new();
|
||||||
|
compatible.default_ttl_seconds = 40;
|
||||||
|
let default_plan = plan(StatusCode::OK, &empty_headers, &compatible, Duration::ZERO)
|
||||||
|
.expect("compatible default ttl also applies to otherwise eligible headerless 200");
|
||||||
|
assert_eq!(default_plan.ttl, 40);
|
||||||
|
assert!(plan(StatusCode::OK, &empty_headers, &strict, Duration::ZERO).is_none());
|
||||||
|
for blocked in ["no-store", "private"] {
|
||||||
|
assert!(plan(StatusCode::OK, &headers(blocked), &compatible, Duration::ZERO).is_none());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn explicit_zero_grace_and_stale_if_error_are_preserved() {
|
fn explicit_zero_grace_and_stale_if_error_are_preserved() {
|
||||||
let compatible = Settings::default();
|
let compatible = Settings::default();
|
||||||
@@ -425,7 +453,7 @@ mod varnish_compatible_tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn positive_fallback_ttl_reuses_only_public_no_cache_entries() {
|
async fn positive_fallback_ttl_reuses_no_cache_even_without_public() {
|
||||||
let cache = Cache::new(1);
|
let cache = Cache::new(1);
|
||||||
let settings = Settings {
|
let settings = Settings {
|
||||||
default_ttl_seconds: 75,
|
default_ttl_seconds: 75,
|
||||||
@@ -442,7 +470,7 @@ mod varnish_compatible_tests {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut response = Response::new(Body::from("public css"));
|
let mut response = Response::new(Body::from("public css"));
|
||||||
*response.headers_mut() = headers("public, no-cache");
|
*response.headers_mut() = headers("no-cache");
|
||||||
let p = plan(
|
let p = plan(
|
||||||
StatusCode::OK,
|
StatusCode::OK,
|
||||||
response.headers(),
|
response.headers(),
|
||||||
@@ -460,7 +488,7 @@ mod varnish_compatible_tests {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
let hit = cache
|
let hit = cache
|
||||||
.get(&ticket)
|
.get(&ticket)
|
||||||
.expect("explicit public override allows fresh HIT without ETag");
|
.expect("explicit compatible override allows fresh HIT without public or ETag");
|
||||||
assert!(hit.remaining_ttl > 0);
|
assert!(hit.remaining_ttl > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+293
-164
@@ -44,6 +44,7 @@ fn vcl_tokens(source: &str) -> Result<Vec<(VclToken, usize)>> {
|
|||||||
}
|
}
|
||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
|
ensure!(index + 1 < bytes.len(), "line {line}: unterminated block comment");
|
||||||
index += 2;
|
index += 2;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -59,13 +60,36 @@ fn vcl_tokens(source: &str) -> Result<Vec<(VclToken, usize)>> {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if byte == b'"' {
|
if byte == b'"' {
|
||||||
let start = index + 1;
|
// Quoted strings must support escaped quotes/backslashes. Keep
|
||||||
let end = source[start..]
|
// regex/backreference escapes such as \\s and \\1 literally: they
|
||||||
.find('"')
|
// belong to the VCL expression, not to the tokenizer.
|
||||||
.map(|offset| start + offset)
|
index += 1;
|
||||||
.ok_or_else(|| anyhow::anyhow!("line {line}: unterminated string"))?;
|
let string_line = line;
|
||||||
tokens.push((VclToken::Str(source[start..end].to_owned()), line));
|
let mut value = String::new();
|
||||||
index = end + 1;
|
let mut terminated = false;
|
||||||
|
while index < bytes.len() {
|
||||||
|
match bytes[index] {
|
||||||
|
b'"' => {
|
||||||
|
index += 1;
|
||||||
|
terminated = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
b'\\' if index + 1 < bytes.len()
|
||||||
|
&& (bytes[index + 1] == b'"' || bytes[index + 1] == b'\\') =>
|
||||||
|
{
|
||||||
|
value.push(bytes[index + 1] as char);
|
||||||
|
index += 2;
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
let ch = source[index..].chars().next().expect("valid UTF-8");
|
||||||
|
if ch == '\n' { line += 1; }
|
||||||
|
value.push(ch);
|
||||||
|
index += ch.len_utf8();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ensure!(terminated, "line {string_line}: unterminated string");
|
||||||
|
tokens.push((VclToken::Str(value), string_line));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if byte.is_ascii_alphabetic() || byte == b'_' {
|
if byte.is_ascii_alphabetic() || byte == b'_' {
|
||||||
@@ -431,62 +455,83 @@ fn vcl_atom(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcl_conditions(
|
/// Compile supported VCL boolean expressions into disjunctive normal form.
|
||||||
expr: &VclExpr,
|
/// Unlike flattening elsif/else or nested if statements, this preserves
|
||||||
stage: RuleStage,
|
/// earlier branch guards and lets terminal returns stop the correct path.
|
||||||
) -> std::result::Result<(RuleMatch, Vec<RuleCondition>), String> {
|
fn vcl_clauses(
|
||||||
let single = |expr: &VclExpr| -> std::result::Result<RuleCondition, String> {
|
expr: &VclExpr, stage: RuleStage, negate: bool,
|
||||||
|
) -> std::result::Result<Vec<Vec<RuleCondition>>, String> {
|
||||||
match expr {
|
match expr {
|
||||||
VclExpr::Atom(tokens) => vcl_atom(tokens, stage, false).map(|atom| atom.condition),
|
VclExpr::Atom(tokens) => Ok(vec![vec![vcl_atom(tokens, stage, negate)?.condition]]),
|
||||||
VclExpr::Not(inner) => match inner.as_ref() {
|
VclExpr::Not(inner) => vcl_clauses(inner, stage, !negate),
|
||||||
VclExpr::Atom(tokens) => vcl_atom(tokens, stage, true).map(|atom| atom.condition),
|
VclExpr::And(items) | VclExpr::Or(items) => {
|
||||||
_ => Err("negated groups are not supported".into()),
|
let product = matches!(expr, VclExpr::And(_)) != negate;
|
||||||
},
|
let mut result: Vec<Vec<RuleCondition>> = vec![Vec::new()];
|
||||||
_ => Err("nested && / || groups are not supported".into()),
|
for item in items {
|
||||||
|
let next = vcl_clauses(item, stage, negate)?;
|
||||||
|
if product {
|
||||||
|
let mut joined = Vec::new();
|
||||||
|
for previous in &result {
|
||||||
|
for conditions in &next {
|
||||||
|
if previous.len() + conditions.len() > MAX_RULE_CONDITIONS {
|
||||||
|
return Err("VCL condition is too complex for cache rules".into());
|
||||||
|
}
|
||||||
|
let mut combined = previous.clone();
|
||||||
|
combined.extend(conditions.iter().cloned());
|
||||||
|
joined.push(combined);
|
||||||
|
if joined.len() > MAX_CACHE_RULES {
|
||||||
|
return Err("VCL condition expansion exceeds rule limit".into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = joined;
|
||||||
|
} else {
|
||||||
|
if result.len() == 1 && result[0].is_empty() { result.clear(); }
|
||||||
|
result.extend(next);
|
||||||
|
if result.len() > MAX_CACHE_RULES {
|
||||||
|
return Err("VCL condition expansion exceeds rule limit".into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(result)
|
||||||
}
|
}
|
||||||
};
|
|
||||||
match expr {
|
|
||||||
VclExpr::And(items) => Ok((
|
|
||||||
RuleMatch::All,
|
|
||||||
items
|
|
||||||
.iter()
|
|
||||||
.map(single)
|
|
||||||
.collect::<std::result::Result<_, _>>()?,
|
|
||||||
)),
|
|
||||||
VclExpr::Or(items) => Ok((
|
|
||||||
RuleMatch::Any,
|
|
||||||
items
|
|
||||||
.iter()
|
|
||||||
.map(single)
|
|
||||||
.collect::<std::result::Result<_, _>>()?,
|
|
||||||
)),
|
|
||||||
other => Ok((RuleMatch::All, vec![single(other)?])),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn query_params_from_regex(pattern: &str) -> Vec<String> {
|
|
||||||
static CLASS: std::sync::LazyLock<regex::Regex> = std::sync::LazyLock::new(|| {
|
/// Only recognise the well-known tracking-query removal pattern. The older
|
||||||
regex::Regex::new(r"\[[^\]]*\][+*]?|\.\*|\.\+").expect("static regex")
|
/// heuristic extracted plausible words from *any* regex, which could turn a
|
||||||
});
|
/// path rewrite into unrelated query stripping. Unsupported rewrites must be
|
||||||
let simplified = CLASS.replace_all(pattern, "*");
|
/// warned about rather than executed differently from their VCL source.
|
||||||
|
fn query_params_from_regex(pattern: &str) -> Option<Vec<String>> {
|
||||||
|
let suffix = pattern
|
||||||
|
.strip_prefix(r"(\?|&)(")
|
||||||
|
.or_else(|| pattern.strip_prefix("([?&])("))?
|
||||||
|
.strip_suffix(")=[^&]*")
|
||||||
|
.or_else(|| {
|
||||||
|
pattern.strip_prefix(r"(\?|&)(")
|
||||||
|
.or_else(|| pattern.strip_prefix("([?&])("))?
|
||||||
|
.strip_suffix(")=[^&]+")
|
||||||
|
})?;
|
||||||
let mut params = Vec::new();
|
let mut params = Vec::new();
|
||||||
for token in
|
for part in suffix.split('|') {
|
||||||
simplified.split(|c: char| !(c.is_ascii_alphanumeric() || matches!(c, '_' | '-' | '*')))
|
let item = if let Some(prefix) = part.strip_suffix("[a-z]+")
|
||||||
|
.or_else(|| part.strip_suffix("[^=&]*"))
|
||||||
|
.or_else(|| part.strip_suffix("[^=&]+"))
|
||||||
{
|
{
|
||||||
if token.len() > 64
|
format!("{prefix}*")
|
||||||
|| !token
|
} else {
|
||||||
.chars()
|
part.to_owned()
|
||||||
.next()
|
};
|
||||||
.is_some_and(|c| c.is_ascii_alphabetic())
|
if item.len() > 64
|
||||||
|
|| !item.as_bytes().first().is_some_and(u8::is_ascii_alphabetic)
|
||||||
|
|| !item.bytes().all(|byte| byte.is_ascii_alphanumeric() || matches!(byte, b'_' | b'-' | b'*'))
|
||||||
{
|
{
|
||||||
continue;
|
return None;
|
||||||
}
|
}
|
||||||
let token = token.to_owned();
|
if !params.contains(&item) { params.push(item); }
|
||||||
if !params.contains(&token) {
|
|
||||||
params.push(token);
|
|
||||||
}
|
}
|
||||||
}
|
(!params.is_empty()).then_some(params)
|
||||||
params
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn vcl_actions(
|
fn vcl_actions(
|
||||||
@@ -504,16 +549,17 @@ fn vcl_actions(
|
|||||||
.first()
|
.first()
|
||||||
.map(|word| word.to_ascii_lowercase())
|
.map(|word| word.to_ascii_lowercase())
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let joined = words.join(" ").to_ascii_lowercase();
|
|
||||||
match (stage, first.as_str()) {
|
match (stage, first.as_str()) {
|
||||||
(_, "return") => {
|
(_, "return") => {
|
||||||
let target = words
|
let target = match tokens {
|
||||||
.get(2)
|
[VclToken::Ident(_), VclToken::Sym("("), VclToken::Ident(target), VclToken::Sym(")")] =>
|
||||||
.map(|word| word.to_ascii_lowercase())
|
target.to_ascii_lowercase(),
|
||||||
.unwrap_or_default();
|
_ => return Err("return requires exactly one action: return(action)".into()),
|
||||||
|
};
|
||||||
match (stage, target.as_str()) {
|
match (stage, target.as_str()) {
|
||||||
(RuleStage::Request, "pass" | "pipe") => Ok(vec![RuleAction::Pass]),
|
(RuleStage::Request, "pass") => Ok(vec![RuleAction::Pass]),
|
||||||
(RuleStage::Request, "hash" | "lookup") => Ok(Vec::new()),
|
(RuleStage::Request, "hash") => Ok(vec![RuleAction::Lookup]),
|
||||||
|
(RuleStage::Request, "lookup") => Ok(vec![RuleAction::Lookup]),
|
||||||
(RuleStage::Response, "pass" | "hit_for_pass" | "uncacheable") => {
|
(RuleStage::Response, "pass" | "hit_for_pass" | "uncacheable") => {
|
||||||
Ok(vec![RuleAction::NoStore])
|
Ok(vec![RuleAction::NoStore])
|
||||||
}
|
}
|
||||||
@@ -523,46 +569,68 @@ fn vcl_actions(
|
|||||||
_ => Err(format!("return ({target}) is not supported here")),
|
_ => Err(format!("return ({target}) is not supported here")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(RuleStage::Request, "unset")
|
(RuleStage::Request, "unset") => {
|
||||||
if words
|
let target = words.get(1).cloned().unwrap_or_default();
|
||||||
.get(1)
|
if tokens.len() != 2 { return Err(format!("invalid unset {target} statement")); }
|
||||||
.is_some_and(|word| word.eq_ignore_ascii_case("req.http.cookie")) =>
|
if target.eq_ignore_ascii_case("req.http.cookie") {
|
||||||
{
|
|
||||||
Ok(vec![RuleAction::StripCookies { keep: Vec::new() }])
|
Ok(vec![RuleAction::StripCookies { keep: Vec::new() }])
|
||||||
}
|
} else if target.to_ascii_lowercase().starts_with("req.http.") {
|
||||||
(RuleStage::Request, "set")
|
Ok(vec![RuleAction::RemoveRequestHeader { name: target[9..].to_owned() }])
|
||||||
if words
|
|
||||||
.get(1)
|
|
||||||
.is_some_and(|word| word.eq_ignore_ascii_case("req.url"))
|
|
||||||
&& joined.contains("regsub") =>
|
|
||||||
{
|
|
||||||
let pattern = words
|
|
||||||
.iter()
|
|
||||||
.find(|word| word.contains('?') || word.contains('&') || word.contains("utm"))
|
|
||||||
.cloned()
|
|
||||||
.unwrap_or_default();
|
|
||||||
let params = query_params_from_regex(&pattern);
|
|
||||||
if params.is_empty() {
|
|
||||||
Err("req.url rewrite not recognised as query parameter removal".into())
|
|
||||||
} else {
|
} else {
|
||||||
Ok(vec![RuleAction::StripQuery {
|
Err(format!("unset {target} is not supported"))
|
||||||
params,
|
|
||||||
keep_only: false,
|
|
||||||
}])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(RuleStage::Request, "hash_data") => match words.get(2) {
|
(RuleStage::Request, "set") => {
|
||||||
Some(word)
|
let target = words.get(1).cloned().unwrap_or_default();
|
||||||
if word.to_ascii_lowercase().starts_with("req.http.")
|
if target.eq_ignore_ascii_case("req.url") {
|
||||||
&& !word.eq_ignore_ascii_case("req.http.cookie") =>
|
let pattern = match tokens {
|
||||||
|
[VclToken::Ident(_), VclToken::Ident(_), VclToken::Sym("="),
|
||||||
|
VclToken::Ident(func), VclToken::Sym("("), VclToken::Ident(url),
|
||||||
|
VclToken::Sym(","), VclToken::Str(pattern), VclToken::Sym(","),
|
||||||
|
VclToken::Str(replacement), VclToken::Sym(")")]
|
||||||
|
if func == "regsuball" && url == "req.url" && replacement == r"\1" => pattern,
|
||||||
|
_ => return Err("req.url: only tracking-query regsuball with replacement backreference 1 is supported".into()),
|
||||||
|
};
|
||||||
|
let params = query_params_from_regex(pattern)
|
||||||
|
.ok_or_else(|| "req.url regex cannot be safely converted to query stripping".to_owned())?;
|
||||||
|
Ok(vec![RuleAction::StripQuery { params, keep_only: false }])
|
||||||
|
} else if target.to_ascii_lowercase().starts_with("req.http.") {
|
||||||
|
match (tokens.get(2), tokens.get(3), tokens.len()) {
|
||||||
|
(Some(VclToken::Sym("=")), Some(VclToken::Str(value)), 4) =>
|
||||||
|
Ok(vec![RuleAction::SetRequestHeader {
|
||||||
|
name: target[9..].to_owned(), value: value.clone(),
|
||||||
|
}]),
|
||||||
|
_ => Err(format!("set {target} requires a constant string")),
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Err(format!("set {target} is not supported"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(RuleStage::Request, "hash_data") => match tokens {
|
||||||
|
[VclToken::Ident(_), VclToken::Sym("("), VclToken::Ident(value), VclToken::Sym(")")]
|
||||||
|
if value.eq_ignore_ascii_case("req.url") =>
|
||||||
{
|
{
|
||||||
Ok(vec![RuleAction::HashHeader {
|
// RustProxy always hashes the full request target; adding it
|
||||||
name: word[9..].to_owned(),
|
// again would not change the variant, and is unnecessary.
|
||||||
}])
|
Ok(Vec::new())
|
||||||
}
|
}
|
||||||
_ => Err("hash_data is only imported for a single request header".into()),
|
[VclToken::Ident(_), VclToken::Sym("("), VclToken::Ident(value), VclToken::Sym(")")]
|
||||||
|
if value.eq_ignore_ascii_case("req.http.host") =>
|
||||||
|
{
|
||||||
|
// The normalized authority is already part of the scoped key.
|
||||||
|
Ok(Vec::new())
|
||||||
|
}
|
||||||
|
[VclToken::Ident(_), VclToken::Sym("("), VclToken::Ident(value), VclToken::Sym(")")]
|
||||||
|
if value.to_ascii_lowercase().starts_with("req.http.") =>
|
||||||
|
{
|
||||||
|
Ok(vec![RuleAction::HashHeader { name: value[9..].to_owned() }])
|
||||||
|
}
|
||||||
|
_ => Err("hash_data supports req.url, req.http.Host or one req.http.<header>".into()),
|
||||||
},
|
},
|
||||||
(RuleStage::Response, "set") => {
|
(RuleStage::Response, "set") => {
|
||||||
|
if tokens.len() != 4 || !matches!(tokens.get(2), Some(VclToken::Sym("="))) {
|
||||||
|
return Err("set beresp requires exactly one assignment".into());
|
||||||
|
}
|
||||||
let target = words
|
let target = words
|
||||||
.get(1)
|
.get(1)
|
||||||
.map(|word| word.to_ascii_lowercase())
|
.map(|word| word.to_ascii_lowercase())
|
||||||
@@ -578,20 +646,29 @@ fn vcl_actions(
|
|||||||
"beresp.uncacheable" if value.eq_ignore_ascii_case("true") => {
|
"beresp.uncacheable" if value.eq_ignore_ascii_case("true") => {
|
||||||
Ok(vec![RuleAction::NoStore])
|
Ok(vec![RuleAction::NoStore])
|
||||||
}
|
}
|
||||||
|
"beresp.uncacheable" if value.eq_ignore_ascii_case("false") => {
|
||||||
|
Ok(vec![RuleAction::AllowStore])
|
||||||
|
}
|
||||||
|
name if name.starts_with("beresp.http.") => {
|
||||||
|
if let (Some(VclToken::Str(value)), 4) = (tokens.get(3), tokens.len()) {
|
||||||
|
Ok(vec![RuleAction::SetBackendHeader {
|
||||||
|
name: name[12..].to_owned(), value: value.clone(),
|
||||||
|
}])
|
||||||
|
} else {
|
||||||
|
Err(format!("set {target} requires a constant string"))
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => Err(format!("set {target} is not supported")),
|
_ => Err(format!("set {target} is not supported")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(RuleStage::Response, "unset") => {
|
(RuleStage::Response, "unset") => {
|
||||||
|
if tokens.len() != 2 { return Err("unset beresp requires exactly one header".into()); }
|
||||||
match words.get(1).map(|word| word.to_ascii_lowercase()) {
|
match words.get(1).map(|word| word.to_ascii_lowercase()) {
|
||||||
Some(word) if word == "beresp.http.set-cookie" => {
|
Some(word) if word == "beresp.http.set-cookie" => {
|
||||||
Ok(vec![RuleAction::StripSetCookie])
|
Ok(vec![RuleAction::StripSetCookie])
|
||||||
}
|
}
|
||||||
Some(word)
|
Some(word) if word.starts_with("beresp.http.") => {
|
||||||
if word == "beresp.http.cache-control"
|
Ok(vec![RuleAction::RemoveBackendHeader { name: word[12..].to_owned() }])
|
||||||
|| word == "beresp.http.expires"
|
|
||||||
|| word == "beresp.http.pragma" =>
|
|
||||||
{
|
|
||||||
Ok(vec![RuleAction::IgnoreCacheControl])
|
|
||||||
}
|
}
|
||||||
Some(word) => Err(format!("unset {word} is not supported")),
|
Some(word) => Err(format!("unset {word} is not supported")),
|
||||||
None => Err("unset without a target".into()),
|
None => Err("unset without a target".into()),
|
||||||
@@ -603,8 +680,8 @@ fn vcl_actions(
|
|||||||
.strip_prefix("resp.http.")
|
.strip_prefix("resp.http.")
|
||||||
.or_else(|| target.strip_prefix("RESP.HTTP."))
|
.or_else(|| target.strip_prefix("RESP.HTTP."))
|
||||||
.ok_or_else(|| format!("set {target} is not supported"))?;
|
.ok_or_else(|| format!("set {target} is not supported"))?;
|
||||||
match (tokens.get(3), tokens.len()) {
|
match (tokens.get(2), tokens.get(3), tokens.len()) {
|
||||||
(Some(VclToken::Str(value)), 4) => Ok(vec![RuleAction::SetHeader {
|
(Some(VclToken::Sym("=")), Some(VclToken::Str(value)), 4) => Ok(vec![RuleAction::SetHeader {
|
||||||
name: name.to_owned(),
|
name: name.to_owned(),
|
||||||
value: value.clone(),
|
value: value.clone(),
|
||||||
}]),
|
}]),
|
||||||
@@ -614,6 +691,7 @@ fn vcl_actions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
(RuleStage::Deliver, "unset") => {
|
(RuleStage::Deliver, "unset") => {
|
||||||
|
if tokens.len() != 2 { return Err("unset resp requires exactly one header".into()); }
|
||||||
let target = words.get(1).cloned().unwrap_or_default();
|
let target = words.get(1).cloned().unwrap_or_default();
|
||||||
target
|
target
|
||||||
.strip_prefix("resp.http.")
|
.strip_prefix("resp.http.")
|
||||||
@@ -647,18 +725,43 @@ impl VclBuilder {
|
|||||||
fn push(
|
fn push(
|
||||||
&mut self,
|
&mut self,
|
||||||
stage: RuleStage,
|
stage: RuleStage,
|
||||||
match_mode: RuleMatch,
|
guards: &[VclExpr],
|
||||||
conditions: Vec<RuleCondition>,
|
|
||||||
actions: Vec<RuleAction>,
|
actions: Vec<RuleAction>,
|
||||||
|
stop: bool,
|
||||||
|
hash_stage: bool,
|
||||||
line: usize,
|
line: usize,
|
||||||
) {
|
) {
|
||||||
if actions.is_empty() {
|
if actions.is_empty() && !stop { return; }
|
||||||
|
let mut clauses: Vec<Vec<RuleCondition>> = vec![Vec::new()];
|
||||||
|
for guard in guards {
|
||||||
|
let options = match vcl_clauses(guard, stage, false) {
|
||||||
|
Ok(options) => options,
|
||||||
|
Err(error) => {
|
||||||
|
self.warnings.push(format!("line {line}: {error}"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
let mut joined = Vec::new();
|
||||||
|
for prefix in &clauses {
|
||||||
|
for conditions in &options {
|
||||||
|
if prefix.len() + conditions.len() > MAX_RULE_CONDITIONS {
|
||||||
|
self.warnings.push(format!("line {line}: condition limit reached"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let mut combination = prefix.clone();
|
||||||
|
combination.extend(conditions.iter().cloned());
|
||||||
|
joined.push(combination);
|
||||||
|
if joined.len() > MAX_CACHE_RULES {
|
||||||
|
self.warnings.push(format!("line {line}: condition expansion limit reached"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
clauses = joined;
|
||||||
|
}
|
||||||
|
for conditions in clauses {
|
||||||
if self.rules.len() >= MAX_CACHE_RULES {
|
if self.rules.len() >= MAX_CACHE_RULES {
|
||||||
self.warnings.push(format!(
|
self.warnings.push(format!("line {line}: rule limit reached, remaining VCL was skipped"));
|
||||||
"line {line}: rule limit reached, the rest of the VCL was skipped"
|
|
||||||
));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let base = format!("vcl-{}-{line}", stage.label());
|
let base = format!("vcl-{}-{line}", stage.label());
|
||||||
@@ -669,21 +772,20 @@ impl VclBuilder {
|
|||||||
index += 1;
|
index += 1;
|
||||||
}
|
}
|
||||||
let rule = Rule {
|
let rule = Rule {
|
||||||
id: id.clone(),
|
id,
|
||||||
name: format!(
|
name: if hash_stage { format!("VCL vcl_hash line {line}") }
|
||||||
"VCL {} line {line}",
|
else { format!("VCL {} line {line}", match stage {
|
||||||
match stage {
|
|
||||||
RuleStage::Request => "vcl_recv",
|
RuleStage::Request => "vcl_recv",
|
||||||
RuleStage::Response => "vcl_backend_response",
|
RuleStage::Response => "vcl_backend_response",
|
||||||
RuleStage::Deliver => "vcl_deliver",
|
RuleStage::Deliver => "vcl_deliver",
|
||||||
}
|
}) },
|
||||||
),
|
|
||||||
enabled: true,
|
enabled: true,
|
||||||
stage,
|
stage,
|
||||||
match_mode,
|
match_mode: RuleMatch::All,
|
||||||
conditions,
|
conditions,
|
||||||
actions,
|
actions: actions.clone(),
|
||||||
stop: false,
|
stop,
|
||||||
|
hash_stage,
|
||||||
vhosts: Vec::new(),
|
vhosts: Vec::new(),
|
||||||
};
|
};
|
||||||
match compile_rule(&rule, RuleOrigin::Global, "") {
|
match compile_rule(&rule, RuleOrigin::Global, "") {
|
||||||
@@ -691,77 +793,104 @@ impl VclBuilder {
|
|||||||
Err(error) => self.warnings.push(format!("line {line}: {error}")),
|
Err(error) => self.warnings.push(format!("line {line}: {error}")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn statements(
|
fn statements(
|
||||||
&mut self,
|
&mut self,
|
||||||
stage: RuleStage,
|
stage: RuleStage,
|
||||||
statements: &[VclStatement],
|
statements: &[VclStatement],
|
||||||
inherited: Option<(RuleMatch, Vec<RuleCondition>)>,
|
guards: &[VclExpr],
|
||||||
|
hash_stage: bool,
|
||||||
) {
|
) {
|
||||||
let mut pending: Vec<RuleAction> = Vec::new();
|
let mut pending: Vec<RuleAction> = Vec::new();
|
||||||
let mut pending_line = 0;
|
let mut pending_line = 0;
|
||||||
let flush = |builder: &mut Self,
|
|
||||||
pending: &mut Vec<RuleAction>,
|
|
||||||
line: usize,
|
|
||||||
inherited: &Option<(RuleMatch, Vec<RuleCondition>)>| {
|
|
||||||
let (mode, conditions) = inherited.clone().unwrap_or((RuleMatch::All, Vec::new()));
|
|
||||||
builder.push(stage, mode, conditions, std::mem::take(pending), line);
|
|
||||||
};
|
|
||||||
for statement in statements {
|
for statement in statements {
|
||||||
match statement {
|
match statement {
|
||||||
VclStatement::Simple(tokens, line) => match vcl_actions(tokens, stage) {
|
VclStatement::Simple(tokens, line) => match if !hash_stage
|
||||||
|
&& matches!(tokens.first(), Some(VclToken::Ident(name)) if name == "hash_data")
|
||||||
|
{
|
||||||
|
Err("hash_data is only supported inside sub vcl_hash".to_owned())
|
||||||
|
} else {
|
||||||
|
vcl_actions(tokens, stage)
|
||||||
|
} {
|
||||||
Ok(actions) => {
|
Ok(actions) => {
|
||||||
if pending.is_empty() {
|
if matches!(tokens.get(1), Some(VclToken::Ident(target)) if target == "req.url")
|
||||||
pending_line = *line;
|
&& actions.iter().any(|action| matches!(action, RuleAction::StripQuery { .. }))
|
||||||
|
{
|
||||||
|
// Converting regex rewriting to query parsing is
|
||||||
|
// intentionally not claimed to be byte-for-byte
|
||||||
|
// equivalent (separator and empty-value handling).
|
||||||
|
self.warnings.push(format!(
|
||||||
|
"line {line}: regsuball(req.url, ...) was converted to strip_query; query separators and empty values can differ; review the rule before saving"
|
||||||
|
));
|
||||||
|
if tokens.iter().any(|token| matches!(token,
|
||||||
|
VclToken::Str(value) if value.contains("[a-z]+")))
|
||||||
|
{
|
||||||
|
self.warnings.push(format!(
|
||||||
|
"line {line}: query parameter name class [a-z]+ was approximated as a wildcard"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
if tokens.iter().any(|token| matches!(token,
|
||||||
|
VclToken::Str(value) if value.ends_with(")=[^&]+")))
|
||||||
|
{
|
||||||
|
self.warnings.push(format!(
|
||||||
|
"line {line}: the original regex preserves parameters with empty values, while strip_query also removes them"
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Validate each converted action independently. One
|
||||||
|
// disallowed header must not silently discard the
|
||||||
|
// adjacent, otherwise valid VCL statements.
|
||||||
|
for action in actions {
|
||||||
|
if let Err(error) = validate_action(&action) {
|
||||||
|
self.warnings.push(format!("line {line}: {error}"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if pending.len() >= MAX_RULE_ACTIONS {
|
||||||
|
self.push(stage, guards, std::mem::take(&mut pending),
|
||||||
|
false, hash_stage, pending_line);
|
||||||
|
}
|
||||||
|
if pending.is_empty() { pending_line = *line; }
|
||||||
|
pending.push(action);
|
||||||
|
}
|
||||||
|
// return terminates only the matching branch of this hook,
|
||||||
|
// not the separate vcl_hash hook.
|
||||||
|
let terminal = matches!(tokens.first(), Some(VclToken::Ident(word))
|
||||||
|
if word.eq_ignore_ascii_case("return"));
|
||||||
|
if terminal {
|
||||||
|
self.push(stage, guards, std::mem::take(&mut pending), true,
|
||||||
|
hash_stage, *line);
|
||||||
|
// Unconditional returns terminate this statement block.
|
||||||
|
// Conditional returns terminate at runtime via Rule.stop.
|
||||||
|
if guards.is_empty() { break; }
|
||||||
}
|
}
|
||||||
pending.extend(actions);
|
|
||||||
}
|
}
|
||||||
Err(error) => self.warnings.push(format!("line {line}: {error}")),
|
Err(error) => self.warnings.push(format!("line {line}: {error}")),
|
||||||
},
|
},
|
||||||
VclStatement::If(branches, line) => {
|
VclStatement::If(branches, _line) => {
|
||||||
flush(self, &mut pending, pending_line, &inherited);
|
if !pending.is_empty() {
|
||||||
if inherited.is_some() {
|
self.push(stage, guards, std::mem::take(&mut pending), false,
|
||||||
self.warnings.push(format!(
|
hash_stage, pending_line);
|
||||||
"line {line}: nested if is not imported; flatten it into one condition"
|
|
||||||
));
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
let mut previous: Vec<RuleCondition> = Vec::new();
|
let mut previous = Vec::new();
|
||||||
let mut previous_ok = true;
|
for (condition, body) in branches {
|
||||||
for (index, (condition, body)) in branches.iter().enumerate() {
|
let mut branch_guards = guards.to_vec();
|
||||||
let parsed = match condition {
|
branch_guards.extend(previous.iter().cloned().map(|previous| {
|
||||||
Some(expr) => vcl_conditions(expr, stage),
|
VclExpr::Not(Box::new(previous))
|
||||||
None => {
|
}));
|
||||||
if previous.len() == 1 && previous_ok {
|
if let Some(condition) = condition {
|
||||||
let mut negated = previous[0].clone();
|
branch_guards.push(condition.clone());
|
||||||
negated.negate = !negated.negate;
|
previous.push(condition.clone());
|
||||||
Ok((RuleMatch::All, vec![negated]))
|
|
||||||
} else {
|
|
||||||
Err("else branch after a complex condition is not imported"
|
|
||||||
.into())
|
|
||||||
}
|
}
|
||||||
}
|
self.statements(stage, body, &branch_guards, hash_stage);
|
||||||
};
|
|
||||||
match parsed {
|
|
||||||
Ok((mode, conditions)) => {
|
|
||||||
if index == 0 || condition.is_none() {
|
|
||||||
previous = conditions.clone();
|
|
||||||
} else {
|
|
||||||
previous_ok = false;
|
|
||||||
}
|
|
||||||
self.statements(stage, body, Some((mode, conditions)));
|
|
||||||
}
|
|
||||||
Err(error) => {
|
|
||||||
previous_ok = false;
|
|
||||||
self.warnings.push(format!("line {line}: {error}"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !pending.is_empty() {
|
||||||
|
self.push(stage, guards, pending, false, hash_stage, pending_line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
flush(self, &mut pending, pending_line, &inherited);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn import_vcl(source: &str) -> Result<VclImport> {
|
pub fn import_vcl(source: &str) -> Result<VclImport> {
|
||||||
@@ -795,7 +924,7 @@ pub fn import_vcl(source: &str) -> Result<VclImport> {
|
|||||||
match vcl_stage(&name) {
|
match vcl_stage(&name) {
|
||||||
Some(stage) => {
|
Some(stage) => {
|
||||||
found = true;
|
found = true;
|
||||||
builder.statements(stage, &body, None);
|
builder.statements(stage, &body, &[], name == "vcl_hash");
|
||||||
}
|
}
|
||||||
None => builder
|
None => builder
|
||||||
.warnings
|
.warnings
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ pub(super) enum CachePlan {
|
|||||||
Enabled {
|
Enabled {
|
||||||
force_cache: bool,
|
force_cache: bool,
|
||||||
ignore_cookie: bool,
|
ignore_cookie: bool,
|
||||||
|
vcl_cookie_lookup: bool,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +25,21 @@ impl CachePlan {
|
|||||||
Self::Enabled {
|
Self::Enabled {
|
||||||
force_cache,
|
force_cache,
|
||||||
ignore_cookie: !force_cache && settings.ignore_cookie_for_path(path),
|
ignore_cookie: !force_cache && settings.ignore_cookie_for_path(path),
|
||||||
|
vcl_cookie_lookup: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn with_vcl_cookie_lookup(mut self, allowed: bool) -> Self {
|
||||||
|
if let Self::Enabled { vcl_cookie_lookup, .. } = &mut self {
|
||||||
|
*vcl_cookie_lookup = allowed;
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(super) fn vcl_cookie_lookup(self) -> bool {
|
||||||
|
matches!(self, Self::Enabled { vcl_cookie_lookup: true, .. })
|
||||||
|
}
|
||||||
|
|
||||||
pub(super) fn force_cache(self) -> bool {
|
pub(super) fn force_cache(self) -> bool {
|
||||||
matches!(
|
matches!(
|
||||||
self,
|
self,
|
||||||
@@ -61,8 +74,10 @@ impl CachePlan {
|
|||||||
Self::Enabled {
|
Self::Enabled {
|
||||||
force_cache: true, ..
|
force_cache: true, ..
|
||||||
} => crate::cache::forced_request_policy(method, headers, body_empty),
|
} => crate::cache::forced_request_policy(method, headers, body_empty),
|
||||||
Self::Enabled { .. } => {
|
Self::Enabled { vcl_cookie_lookup, .. } => {
|
||||||
crate::cache::request_policy(method, headers, body_empty, path, has_query, settings)
|
crate::cache::request_policy_with_vcl_cookie(
|
||||||
|
method, headers, body_empty, path, has_query, settings, vcl_cookie_lookup,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -127,26 +127,11 @@ let mut cache_rule_context: Option<Arc<crate::cache::RuleContext>> = None;
|
|||||||
let mut cache_rule_query: Option<Option<String>> = None;
|
let mut cache_rule_query: Option<Option<String>> = None;
|
||||||
let mut cache_rule_variant = String::new();
|
let mut cache_rule_variant = String::new();
|
||||||
let mut cache_rule_pass = false;
|
let mut cache_rule_pass = false;
|
||||||
if !admin_control_plane && !cache_settings.active_for(route.cache) {
|
let mut cache_rule_lookup = false;
|
||||||
if let Some(rules) = cache_settings
|
// VCL request mutations (cookie/query edits) still affect the origin when
|
||||||
.compiled_rules
|
// cache storage is disabled for this route. Storage eligibility is evaluated
|
||||||
.clone()
|
// separately below; administrative/control-plane traffic remains excluded.
|
||||||
.filter(|rules| rules.has_deliver_rules())
|
if !admin_control_plane {
|
||||||
{
|
|
||||||
let rule_request = crate::cache::RuleRequest {
|
|
||||||
host: host.clone(),
|
|
||||||
path: path.to_string(),
|
|
||||||
query: request.uri().query().map(str::to_owned),
|
|
||||||
method: request.method().clone(),
|
|
||||||
headers: request.headers().clone(),
|
|
||||||
client_ip: Some(context.client_ip),
|
|
||||||
};
|
|
||||||
if let Some(sink) = request.extensions().get::<crate::cache::RuleSink>() {
|
|
||||||
sink.set(Arc::new(crate::cache::RuleContext { rules, request: rule_request }));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !admin_control_plane && cache_settings.active_for(route.cache) {
|
|
||||||
if let Some(rules) = cache_settings.compiled_rules.clone() {
|
if let Some(rules) = cache_settings.compiled_rules.clone() {
|
||||||
let mut rule_request = crate::cache::RuleRequest {
|
let mut rule_request = crate::cache::RuleRequest {
|
||||||
host: host.clone(),
|
host: host.clone(),
|
||||||
@@ -158,6 +143,7 @@ if !admin_control_plane && cache_settings.active_for(route.cache) {
|
|||||||
};
|
};
|
||||||
let outcome = rules.evaluate_request(&rule_request, true);
|
let outcome = rules.evaluate_request(&rule_request, true);
|
||||||
if !outcome.matched.is_empty() {
|
if !outcome.matched.is_empty() {
|
||||||
|
outcome.apply_headers(request.headers_mut());
|
||||||
outcome.rewrite_cookies(request.headers_mut());
|
outcome.rewrite_cookies(request.headers_mut());
|
||||||
cache_rule_query = outcome.rewrite_query(request.uri().query());
|
cache_rule_query = outcome.rewrite_query(request.uri().query());
|
||||||
if let Some(query) = &cache_rule_query {
|
if let Some(query) = &cache_rule_query {
|
||||||
@@ -175,6 +161,7 @@ if !admin_control_plane && cache_settings.active_for(route.cache) {
|
|||||||
}
|
}
|
||||||
cache_rule_variant = outcome.hash_variant();
|
cache_rule_variant = outcome.hash_variant();
|
||||||
cache_rule_pass = outcome.pass.is_some();
|
cache_rule_pass = outcome.pass.is_some();
|
||||||
|
cache_rule_lookup = outcome.lookup.is_some();
|
||||||
rule_request.headers = request.headers().clone();
|
rule_request.headers = request.headers().clone();
|
||||||
rule_request.query = request.uri().query().map(str::to_owned);
|
rule_request.query = request.uri().query().map(str::to_owned);
|
||||||
}
|
}
|
||||||
@@ -239,9 +226,10 @@ let cache_plan = cache_plan::CachePlan::new(policy_reason, cache_settings, &path
|
|||||||
.frontend
|
.frontend
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.is_some_and(|frontend| frontend.force_cache.matches(&path, &public_suffix))
|
.is_some_and(|frontend| frontend.force_cache.matches(&path, &public_suffix))
|
||||||
});
|
}).with_vcl_cookie_lookup(cache_rule_lookup && cache_settings.varnish_compatible);
|
||||||
let force_cache = cache_plan.force_cache();
|
let force_cache = cache_plan.force_cache();
|
||||||
let ignore_static_cookie = cache_plan.ignore_cookie();
|
// Explicit VCL hash takes precedence over the static cookie shortcut.
|
||||||
|
let ignore_static_cookie = cache_plan.ignore_cookie() && !cache_plan.vcl_cookie_lookup();
|
||||||
let original_policy = cache_plan.request_policy(
|
let original_policy = cache_plan.request_policy(
|
||||||
request.method(), request.headers(), body_empty, &path,
|
request.method(), request.headers(), body_empty, &path,
|
||||||
request.uri().query().is_some(), cache_settings,
|
request.uri().query().is_some(), cache_settings,
|
||||||
@@ -333,7 +321,10 @@ let effective_policy = cache_plan::combine_policy(original_policy, || {
|
|||||||
request.uri().query().is_some(), cache_settings,
|
request.uri().query().is_some(), cache_settings,
|
||||||
)
|
)
|
||||||
});
|
});
|
||||||
let force_vary_cookie = force_cache && request.headers().contains_key(::http::header::COOKIE);
|
// Cookies admitted through explicit VCL lookup must not be shared between
|
||||||
|
// different Cookie values unless the rule removed Cookie before this point.
|
||||||
|
let force_vary_cookie = (force_cache || cache_plan.vcl_cookie_lookup())
|
||||||
|
&& request.headers().contains_key(::http::header::COOKIE);
|
||||||
let force_vary_authorization = force_cache && request.headers().contains_key(::http::header::AUTHORIZATION);
|
let force_vary_authorization = force_cache && request.headers().contains_key(::http::header::AUTHORIZATION);
|
||||||
let effective_reason = effective_policy.bypass_reason();
|
let effective_reason = effective_policy.bypass_reason();
|
||||||
let revalidation_reason = effective_policy.revalidation_reason();
|
let revalidation_reason = effective_policy.revalidation_reason();
|
||||||
|
|||||||
@@ -168,7 +168,11 @@ if let (Some(ticket), Some(plan), Some(transformed)) =
|
|||||||
cache_settings,
|
cache_settings,
|
||||||
fill_leader.take(),
|
fill_leader.take(),
|
||||||
);
|
);
|
||||||
if cache_settings.proactive_refresh_enabled && proactive_remaining_ttl > 0 {
|
// Avoid refreshing a cookie/credential-keyed entry without its original
|
||||||
|
// VCL variation context: proactive refresh must never collapse users.
|
||||||
|
if cache_settings.proactive_refresh_enabled && proactive_remaining_ttl > 0
|
||||||
|
&& !force_vary_cookie && !force_vary_authorization
|
||||||
|
{
|
||||||
schedule_proactive_refresh(
|
schedule_proactive_refresh(
|
||||||
CacheRefreshContext {
|
CacheRefreshContext {
|
||||||
state: state.clone(),
|
state: state.clone(),
|
||||||
|
|||||||
@@ -112,12 +112,24 @@ if handshake.as_ref().is_some_and(|handshake| {
|
|||||||
"RustProxy: HTTP/1.1 WebSocket upstream returned 2xx without switching protocols\n",
|
"RustProxy: HTTP/1.1 WebSocket upstream returned 2xx without switching protocols\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
let cache_rule_overrides = match (&cache_rule_context, cache_ticket.is_some()) {
|
let cache_rule_overrides = cache_rule_context
|
||||||
(Some(rule_context), true) => rule_context.response_overrides(response.status(), response.headers()),
|
.as_ref()
|
||||||
_ => crate::cache::ResponseOverrides::NONE,
|
.map(|rules| rules.response_overrides(response.status(), response.headers()))
|
||||||
};
|
.unwrap_or(crate::cache::ResponseOverrides::NONE);
|
||||||
if cache_rule_overrides.strip_set_cookie {
|
// VCL backend-response mutations affect both the cache plan and the actual
|
||||||
response.headers_mut().remove(::http::header::SET_COOKIE);
|
// response, including requests that bypass storage.
|
||||||
|
cache_rule_overrides.apply_headers(response.headers_mut());
|
||||||
|
// A shared intermediary downstream must also partition by the credentials
|
||||||
|
// that RustProxy uses internally, not just RustProxy's HOT/COLD variants.
|
||||||
|
for (needed, header) in [
|
||||||
|
(force_vary_cookie, "cookie"),
|
||||||
|
(force_vary_authorization, "authorization"),
|
||||||
|
] {
|
||||||
|
if needed && !crate::cache::varies_on(response.headers(), header) {
|
||||||
|
if let Ok(value) = http::HeaderValue::from_str(header) {
|
||||||
|
response.headers_mut().append(::http::header::VARY, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
let origin_status = response.status();
|
let origin_status = response.status();
|
||||||
crate::cache::normalize_static_cookie_vary(
|
crate::cache::normalize_static_cookie_vary(
|
||||||
|
|||||||
+1
-3
@@ -386,9 +386,7 @@ async fn refresh_cache_once(
|
|||||||
.map(|rules| rules.response_overrides(origin.status(), origin.headers()))
|
.map(|rules| rules.response_overrides(origin.status(), origin.headers()))
|
||||||
.unwrap_or(crate::cache::ResponseOverrides::NONE);
|
.unwrap_or(crate::cache::ResponseOverrides::NONE);
|
||||||
let mut origin = origin;
|
let mut origin = origin;
|
||||||
if rule_overrides.strip_set_cookie {
|
rule_overrides.apply_headers(origin.headers_mut());
|
||||||
origin.headers_mut().remove(::http::header::SET_COOKIE);
|
|
||||||
}
|
|
||||||
let Some(origin_plan) = crate::cache::plan_with(
|
let Some(origin_plan) = crate::cache::plan_with(
|
||||||
origin.status(),
|
origin.status(),
|
||||||
origin.headers(),
|
origin.headers(),
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
"use strict";
|
||||||
|
// Small dependency-free smoke test for the cache-rule editor's VCL output.
|
||||||
|
const fs = require("node:fs");
|
||||||
|
const path = require("node:path");
|
||||||
|
const vm = require("node:vm");
|
||||||
|
const assert = require("node:assert/strict");
|
||||||
|
|
||||||
|
const root = path.resolve(__dirname, "../..");
|
||||||
|
const source = fs.readFileSync(path.join(root, "src/admin/web/cache-rules.js"), "utf8");
|
||||||
|
const sandbox = { window: {} };
|
||||||
|
vm.runInNewContext(source, sandbox, { filename: "cache-rules.js" });
|
||||||
|
const editor = sandbox.window.rustProxyCacheRules;
|
||||||
|
assert.equal(typeof editor?.exportVcl, "function");
|
||||||
|
const vcl = editor.exportVcl([
|
||||||
|
{ id: "r1", stage: "request", conditions: [], actions: [
|
||||||
|
{ type: "remove_request_header", name: "X-Tracking" },
|
||||||
|
{ type: "set_request_header", name: "X-Device", value: "mobile" },
|
||||||
|
{ type: "lookup" },
|
||||||
|
], stop: true },
|
||||||
|
{ id: "r2", stage: "request", hash_stage: true, conditions: [], actions: [
|
||||||
|
{ type: "hash_header", name: "X-Device" },
|
||||||
|
] },
|
||||||
|
{ id: "r3", stage: "response", conditions: [], actions: [
|
||||||
|
{ type: "no_store" }, { type: "allow_store" },
|
||||||
|
{ type: "set_backend_header", name: "Vary", value: "Accept-Language" },
|
||||||
|
] },
|
||||||
|
{ id: "r4", stage: "deliver", conditions: [], actions: [], stop: true },
|
||||||
|
]);
|
||||||
|
for (const statement of [
|
||||||
|
"sub vcl_recv {", "unset req.http.X-Tracking;",
|
||||||
|
'set req.http.X-Device = "mobile";', "return (hash);",
|
||||||
|
"sub vcl_hash {", "hash_data(req.http.X-Device);",
|
||||||
|
"sub vcl_backend_response {", "set beresp.uncacheable = true;",
|
||||||
|
"set beresp.uncacheable = false;", 'set beresp.http.Vary = "Accept-Language";',
|
||||||
|
"sub vcl_deliver {", "return (deliver);",
|
||||||
|
]) assert.ok(vcl.includes(statement), `missing in VCL export: ${statement}`);
|
||||||
|
assert.ok(!vcl.includes("return (lookup);"), "should not generate lookup in recv");
|
||||||
|
assert.equal((vcl.match(/return \(deliver\);/g) || []).length, 1, "single terminal deliver");
|
||||||
|
console.log("PASS: cache rules JS export, request headers, store override, vcl_hash and terminal deliver");
|
||||||
Reference in new issue
Block a user