diff --git a/SHA256SUMS b/SHA256SUMS index f30b512..693e777 100644 --- a/SHA256SUMS +++ b/SHA256SUMS @@ -2,7 +2,7 @@ 4140a2956264b44f259e6a37fc00ba02097bbe68b09296e04d3d243c1287129b .env.example e76e688874828e3743d03693b1d2872b9633b4db09909673786caf30f7cfe489 .gitignore 75a02969103a9a28563e10a9f2dd43bbbf9d9968b8d17f8ae4bb6ef11b1a9fe9 AGENTS.md -ed7a7c9c6441063fbe77621606dfb3280eeb0a52f2753f502359ec71b716e1ac CHANGELOG.md +fef44535fd191d7d9b9e38c0a98b4c545a4f3889ac13f91a0e596660ffd5f491 CHANGELOG.md 1a21e0a1e20786445750186c221a21d5266aa16c6e8f220d4c5af1f39b572d51 Cargo.lock 21e77407c22125c0aaebb1cd5164fd5d38eef6555ef62ef363f42ae0966683cd Cargo.toml 788745d4f70a0382c6280020afbd48844bb2af65e835a826852143f8132cdeca Dockerfile @@ -45,7 +45,7 @@ c0940a4b323d71931cf2ad4ad24d58b6d6bfd49af90c6e3fc91fcbe2b4cf312f docs/ACCESS.md 9c9e6c56ae9d714a5a99bffd39cb2d506991af5e67f034d41fe45210c95ac5ca docs/CONFIGURATION.md fec29ce846d6705eb45819d85d382f28e28a146b265feab2e4c7cce2a35e5883 docs/CUSTOM_LOCATIONS.md 5776a6e59df079a8788df00f031cb366f12718f5336ddabd90a953aed2f8b1f7 docs/DASHBOARD.md -86c085b1d9acc7140bc7e3ecd85974b5e42614ebeaed675561b33bf82b98bca6 docs/DOCKER_DISCOVERY.md +66cad89e66b7b2d8bc988823e60488c6914885e87aae0cc7d91c7fb95dd14f97 docs/DOCKER_DISCOVERY.md bd0bb5583bf171dc2cf73b56492184f6d7a69bf33db5f25c5396ed6c3300b400 docs/FEATURES.md 2c5f97b12be53db32c7e2888d23c0ef1d82d1742df44f7e60ea818dc801a719a docs/INSTALL.md 6e37859bf0dced99d4a7db93790cb38fcd90191932827946d5223eaa4c784fce docs/LOGS.md @@ -229,22 +229,22 @@ e799e0406c7ff54cbf71faf704a20265bdf5180a8ed2f26388d0775231365410 src/admin/web/ b7ead49224a4ec67181d3f24f9d9634bd6d76756f826a4d5d993300637d1d8f3 src/admin/web/app/stream-dashboard.js 7de070cc8cdde45d7e0932259299e341e25b32c9ffbd87e4fcce934d0f090de4 src/admin/web/app/web-overview.js 3563508f45f740f0cc0e84c72eb79045c0cb54d6fa06a50326a3a219221e0010 src/admin/web/cache-panel.js -d8e791a018efb547fa5da51f7c17899fa6a49b853fea254e00a4dd61c74b4a98 src/admin/web/cache-rules.js +9cc81e0495d4afbecc49d0d04d039fa47795beb5d63022495a8ab3609640a9f3 src/admin/web/cache-rules.js 6288b0a8228d828ac2e2535ace2d1aefd1c04011e789eb97f7279129874ac35c src/admin/web/certificate-api.js f554ca7179fe4d97ae24aa004d4bc9ada5f84fc78257891933a7fed728006ef8 src/admin/web/css/00-tokens.css 741a0cc0c122215d738b7cb62a032e6f1892486e3193083e1cc7a8d4cc90a540 src/admin/web/css/10-base.css e360478a3dc3a3b316cc94712480f8c5cb1f8e78e5240613deda240ac4c16abe src/admin/web/css/20-shell.css -5d676a34a081300b9844d996654e4880f803468c6d87d1674dfef25549a11511 src/admin/web/css/30-overview.css -fef9a90926ae90b61f24a989488ca2c49addb3df70452953d316899b3bf18d84 src/admin/web/css/40-editors.css -53f59ad39e41271fca2ea1a0ed694be1e80d28bbfc934558bd48b9227723f9d2 src/admin/web/css/50-settings.css +23b5f5c1b28944b7a911eaf5058c006df40f47874eddaa36512baccd1c9cfd6c src/admin/web/css/30-overview.css +6ba5e21e0a8eb85f2bd6937b14e67dd151fdf97362e2d6c179acdaaafc3d6d3c src/admin/web/css/40-editors.css +5584e779de815a86efd3cd2514d7973a38e3fda20f7e8aaa9900fa724b204018 src/admin/web/css/50-settings.css a2941410b885ac4487c2dc9003fb1d1073c163d707b5d085a15d9e8a8a628e03 src/admin/web/css/60-monitoring.css -0b898103ac6e445734c8f54d505788642c0670530bb4833b1df979b786446b3e src/admin/web/css/70-responsive.css +faab7ea6b07cdb69cbba3b9db74cc995ce12a7ab097fdc053227ddab72b23cdb src/admin/web/css/70-responsive.css 8009afdb04d5170687816730cc930a22fead1fe0248835ca7e8de81d6907395d src/admin/web/css/README.md 8241bd9489dfed082863948829a44a49bf0a8e9cd63c55809655109e393e0918 src/admin/web/css/manifest.json 78bf6179f769b68d518028464697e50dea5d75e33ecb1b89d88e2c2b01e86bf2 src/admin/web/dashboard-defaults.json 355046ecb80ce6adb73ceabd29825b0cf79ca364771070cedd5eb44760fae890 src/admin/web/dashboard-widgets.json 50d1ebcbaf4d0b2968da23bb943fc3f67131c5d32df3f61d23ff37aad9da5b81 src/admin/web/demo.html -eb5aad8daaa3d2201bacafca6863e77bbef0932ac2027287e87018e0838dd8b5 src/admin/web/docker.js +10f19073034f0aacff8903d44e9b4bede56cd781b568c5a47c89ec8e4b864824 src/admin/web/docker.js 8bf5d1f4f06d6e87536d808a680bf3d3a0c90c1637df0e58da667fd22ad4782d src/admin/web/docs.css aeffd403fa1823df7d9fa4c48280b4033b2d15e4cb9f66608caff89290de0a52 src/admin/web/docs.html 306db8db9e4d651a85e09dbc15464e7f920d7fe5bd9ec9d1d8068321eb0106ab src/admin/web/docs.js @@ -585,6 +585,7 @@ e5f5fbe702f66bfcbcbc1d1f3cd3d89bdbb929bb86aed94868a2a06a4b9e59e3 src/web_server b791762b4ab7a43c3be19df84e523faf3dfb4df055f66d02178f93edb60d2204 src/web_server/serve.rs 714418c86ab241020a561fcf662a8fe324a6a70cc2fd3a313c56d7939c14b9e8 src/web_server/tests.rs f00743af2cf4a5952caef7a1dcf68e7817b5599a252a9973e1c22045517c0b0e tests/fixtures/argon2id.json +ebe8f1318aa55c381062988badd09e0cc9e9b40609252435dcf4ce2b230aeaa9 tests/panel_cache_stats_contract.js 102b83171a6429b6375d8001d6c5294702385cd58ee55727cb657b1f3566e877 tests/panel_icons_browser.py c4030b7d224553312012b1f25153dd3545e83de7bccff2894c0e8f7e0e84b721 tests/panel_icons_contract.js 886c89e8517f34af5e2aef9672a8de559f94c536b028f1b9cadf2a2a7220d826 tests/panel_interface_contract.py diff --git a/docs/DOCKER_DISCOVERY.md b/docs/DOCKER_DISCOVERY.md index 440b613..e1b45e3 100644 --- a/docs/DOCKER_DISCOVERY.md +++ b/docs/DOCKER_DISCOVERY.md @@ -135,14 +135,14 @@ Endpoints that belong together are **grouped**: every published port of one Dock In **Docker vhosts**, select the service and set: | Option | Guidance | -|---|---| +| --- | --- | | **Hostname / master domain / aliases** | By default, the sanitized Docker container name expands under the selected master domain (one of the agent domains), without an image or port suffix. A custom short name or a full name inside the agent domains overrides it; aliases may use any agent domain. Containers exposing multiple published TCP ports require distinct manually assigned hostnames to publish both ports. Configure public DNS separately. | | **Backend IP/port** | Pick a detected, reachable Docker-host address or the configured automatic option. Docker host/firewall binding must permit RustProxy to connect. | | **HTTP / HTTPS upstream** | Match the container's actual service protocol; review origin TLS verification and Host behavior. | | **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. | | **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, 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. | **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. | To deliberately assign a domain not covered by any of the agent's **selected certificates**, enable **Accept certificate/domain mismatch** immediately below **Backend host IP** in the per-service editor and confirm the risk. This records `allow_certificate_mismatch: true` on that publication only. Without consent, the server rejects the incompatible mapping. The client browser may still reject the TLS handshake; a matching SAN certificate is strongly preferred. The agent's own outbound TLS fingerprint validation is unaffected. diff --git a/src/admin/web/cache-rules.js b/src/admin/web/cache-rules.js index 989f4d0..177f926 100644 --- a/src/admin/web/cache-rules.js +++ b/src/admin/web/cache-rules.js @@ -190,10 +190,17 @@ window.rustProxyCacheRules = (() => { return targets || (envelope?.config?.vhosts || []).map(vhost => ({ id: vhost.id, hosts: vhost.frontend?.hosts || [], docker: false })); } const targetTitle = target => target.docker ? `${target.hosts?.[0] || target.id} (Docker)` : target.id; - let hits = {}; - async function loadHits() { - if (!authenticated) return; - try { hits = (await api("/api/cache/rules/stats")).hits || {}; } catch { hits = {}; } + let hits = {}, hitsRequest = null, hitsFetchedAt = 0; + const HITS_REFRESH_MS = 15_000; + function loadHits() { + if (!authenticated) return Promise.resolve(); + if (hitsRequest) return hitsRequest; + if (Date.now() - hitsFetchedAt < HITS_REFRESH_MS) return Promise.resolve(); + hitsRequest = api("/api/cache/rules/stats") + .then(data => { hits = data.hits || {}; }) + .catch(() => { hits = {}; }) + .finally(() => { hitsFetchedAt = Date.now(); hitsRequest = null; }); + return hitsRequest; } function select(values, current, label) { const node = el("select"); for (const [value, text] of values) { const option = el("option", text); option.value = value; node.append(option); } node.value = current; if (label) node.setAttribute("aria-label", label); return node; @@ -242,8 +249,10 @@ window.rustProxyCacheRules = (() => { for (const isolated of [tester.node, importBox]) for (const type of ["input", "change"]) isolated.addEventListener(type, event => event.stopPropagation()); root.addEventListener("keydown", event => { if (event.key === "Enter" && event.target.matches?.("input:not([type=checkbox])")) event.preventDefault(); }); function taken() { return new Set(rules.map(rule => rule.id)); } - void loadTargets(); - document.addEventListener("rustproxy-cache-targets", () => { if (root.isConnected && scope === "global" && open.size) render(); }); + if (scope === "global") { + void loadTargets(); + document.addEventListener("rustproxy-cache-targets", () => { if (root.isConnected && open.size) render(); }); + } function renderNotices() { notices.replaceChildren(); if (scope !== "vhost") return; @@ -252,6 +261,12 @@ window.rustProxyCacheRules = (() => { if (globals.length) notices.append(el("p", t("cacheRulesGlobalApply").replace("{count}", globals.length).replace("{names}", globals.slice(0, 6).map(rule => rule.name || rule.id).join(", ") + (globals.length > 6 ? "…" : "")), "fine")); for (const note of conflictsFor(rules, globals)) notices.append(el("p", note, "fine cache-rules-notice")); } + function updateHitCounts() { + for (const node of list.querySelectorAll(".cache-rule-hits")) { + const count = hits[node.dataset.hitKey]; + node.textContent = count == null ? "" : t("cacheRulesHits").replace("{count}", fmt(count)); + } + } function render() { list.replaceChildren(...rules.map((rule, index) => ruleCard(rule, index))); empty.hidden = rules.length > 0; @@ -276,6 +291,7 @@ window.rustProxyCacheRules = (() => { title.addEventListener("click", () => { if (open.has(rule.id)) open.delete(rule.id); else open.add(rule.id); render(); }); const hitKey = scope === "vhost" ? `vhost:${vhostId}:${rule.id}` : `global:${rule.id}`; const hitCount = el("span", hits[hitKey] != null ? t("cacheRulesHits").replace("{count}", fmt(hits[hitKey])) : "", "fine cache-rule-hits"); + hitCount.dataset.hitKey = hitKey; const actions = el("span", undefined, "cache-rule-actions"); const up = el("button", "↑", "quiet"); up.type = "button"; up.disabled = index === 0; up.setAttribute("aria-label", t("cacheRulesMoveUp")); up.addEventListener("click", () => move(index, index - 1)); const down = el("button", "↓", "quiet"); down.type = "button"; down.disabled = index === rules.length - 1; down.setAttribute("aria-label", t("cacheRulesMoveDown")); down.addEventListener("click", () => move(index, index + 1)); @@ -392,7 +408,7 @@ window.rustProxyCacheRules = (() => { 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 vhostSelect = select([["", t("cacheRulesTesterNoVhost")], ...targetList().map(target => [target.id, targetTitle(target)])], vhostId, t("cacheRulesTesterVhost")); - document.addEventListener("rustproxy-cache-targets", () => { + if (scope === "global") document.addEventListener("rustproxy-cache-targets", () => { 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.value = [...vhostSelect.options].some(option => option.value === current) ? current : ""; @@ -473,9 +489,13 @@ window.rustProxyCacheRules = (() => { } return rules.map(rule => clean(rule, scope === "global")); } + function refreshHits() { + if (!rules.length) return Promise.resolve(); + return loadHits().then(updateHitCounts); + } render(); - void loadHits().then(render); - return { node: root, read, ignoreGlobal: () => ignoreGlobal, set(next) { rules = (next || []).map(normalize); open = new Set(); render(); }, refreshHits: () => loadHits().then(render) }; + if (options.autoLoadHits !== false) void refreshHits(); + return { node: root, read, ignoreGlobal: () => ignoreGlobal, set(next) { rules = (next || []).map(normalize); open = new Set(); render(); }, refreshHits }; } return { create, exportVcl, TEMPLATES }; })(); diff --git a/src/admin/web/docker.js b/src/admin/web/docker.js index 7fc214a..e842a25 100644 --- a/src/admin/web/docker.js +++ b/src/admin/web/docker.js @@ -405,7 +405,7 @@ data.token = reply.token; } if (!name.value.trim() && data.name) { name.value = data.name; fire(name); } - endpoint.value = data.endpoint; token.value = data.token; fingerprint.value = data.fingerprint; [endpoint, token, fingerprint].forEach(fire); + endpoint.value = data.endpoint; token.value = data.token; fingerprint.value = data.fingerprint;[endpoint, token, fingerprint].forEach(fire); provisionInput.value = ""; provisionStatus.textContent = t("dockerProvisionApplied").replace("{endpoint}", data.endpoint); provisionStatus.classList.remove("is-error"); updateSecurityBadge(row); setSettingsDirty("docker-agents-form"); } catch (error) { provisionStatus.textContent = error.message; provisionStatus.classList.add("is-error"); } @@ -683,9 +683,10 @@ 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"))); 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: "" }); + const rules = window.rustProxyCacheRules?.create?.({ scope: "vhost", vhostId, rules: assignment?.cache_rules || [], ignoreGlobal: assignment?.cache_ignore_global_rules === true, ignoreId: "", autoLoadHits: false }); if (rules?.node) { rules.node.classList.add("docker-cache-rules"); details._rules = rules; } details.append(grid); if (rules?.node) details.append(rules.node); + details.addEventListener("toggle", () => { if (details.open && !details.hidden) void rules?.refreshHits?.(); }); const sync = () => { details.hidden = !enabled.checked; }; enabled.addEventListener("change", sync); sync(); return details; }