v0.39.0
This commit is contained in:
1 parent
5e43752041
commit
15425fb803
34 files changed
+1423
-89
No files matched your search
@@ -135,7 +135,7 @@
|
||||
}
|
||||
function configure() {
|
||||
const selected = scope(); const items = [el("option", t("logAllVhosts"))]; items[0].value = "*";
|
||||
for (const host of envelope?.config.vhosts || []) { const item = el("option", `${host.id} / ${host.frontend.hosts.join(", ")}`); item.value = host.id; items.push(item); }
|
||||
for (const host of staticData?.vhosts || []) { const item = el("option", host.label || `${host.id} / ${(host.hosts || []).join(", ")}`); item.value = host.id; item.title = host.id; items.push(item); }
|
||||
$("cache-scope").replaceChildren(...items); $("cache-scope").value = items.some(e => e.value === selected) ? selected : "*";
|
||||
}
|
||||
function render(data) {
|
||||
@@ -255,11 +255,24 @@
|
||||
try {
|
||||
const base = `/api/cache?${query}`;
|
||||
if (staticData) query.set("view", "live");
|
||||
let data = await api(`/api/cache?${query}`, { signal });
|
||||
if (staticData && data.revision !== staticRevision) data = await api(base, { signal });
|
||||
let data;
|
||||
try {
|
||||
data = await api(`/api/cache?${query}`, { signal });
|
||||
} catch (error) {
|
||||
// A label-only Docker publication can disappear from the
|
||||
// effective catalog. Recover from its now-invalid scope.
|
||||
if (error?.status !== 404 || scope() === "*") throw error;
|
||||
$("cache-scope").value = "*";
|
||||
offset = 0; resetLiveChart("*");
|
||||
staticData = null; staticRevision = null;
|
||||
query.delete("vhost"); query.delete("view"); query.set("offset", "0");
|
||||
data = await api(`/api/cache?${query}`, { signal });
|
||||
}
|
||||
if (staticData && (data.revision !== staticRevision || data.catalog_version !== staticData.catalog_version)) data = await api(base, { signal });
|
||||
if (data.settings && Array.isArray(data.vhosts)) {
|
||||
staticData = { settings: data.settings, vhosts: data.vhosts };
|
||||
staticData = { settings: data.settings, vhosts: data.vhosts, catalog_version: data.catalog_version };
|
||||
staticRevision = data.revision;
|
||||
configure(); // Effective Docker vhosts can change without a saved config revision.
|
||||
} else if (staticData) {
|
||||
data = { ...staticData, ...data };
|
||||
}
|
||||
|
||||
@@ -165,6 +165,18 @@ window.rustProxyCacheRules = (() => {
|
||||
{ name: t("cacheRuleTplStaticCookies"), stage: "request", match: "all", conditions: [{ field: "extension", operator: "equals", values: ["css", "js", "mjs", "png", "jpg", "jpeg", "gif", "webp", "avif", "svg", "ico", "woff", "woff2"] }], actions: [{ type: "strip_cookies", keep: [] }] },
|
||||
{ name: t("cacheRuleTplStaticTtl"), stage: "response", 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: "ttl", seconds: 2592000 }, { type: "strip_set_cookie" }] },
|
||||
],
|
||||
// Opt-in CDN cookie policy. Never strip a mixed Cookie header: it may
|
||||
// contain session/authentication state required by the origin.
|
||||
cdn: () => {
|
||||
const technical = "(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)";
|
||||
return [
|
||||
{ name: t("cacheRuleTplCdnMethods"), stage: "request", match: "all", conditions: [{ field: "method", operator: "equals", values: ["GET", "HEAD"], negate: true }], actions: [{ type: "pass" }], stop: true },
|
||||
{ name: t("cacheRuleTplCdnPrivate"), stage: "request", match: "all", conditions: [{ field: "path", operator: "regex", values: ["^/(admin|api|auth|login|logout|panel|konto|dashboard)(/|$)"] }], actions: [{ type: "pass" }], stop: true },
|
||||
{ name: t("cacheRuleTplCdnAuth"), stage: "request", match: "all", conditions: [{ field: "header", name: "Authorization", operator: "exists" }], actions: [{ type: "pass" }], stop: true },
|
||||
{ name: t("cacheRuleTplCdnStrip"), stage: "request", match: "all", conditions: [{ field: "header", name: "Cookie", operator: "regex", values: [`^${technical}=[^;]*(?:;[ \\t]*${technical}=[^;]*)*$`] }], actions: [{ type: "strip_cookies", keep: [] }] },
|
||||
{ name: t("cacheRuleTplCdnRemaining"), stage: "request", match: "all", conditions: [{ field: "header", name: "Cookie", operator: "exists" }], actions: [{ type: "pass" }], stop: true },
|
||||
];
|
||||
},
|
||||
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" }] }],
|
||||
language: () => [{ name: t("cacheRuleTplLanguage"), stage: "request", match: "all", conditions: [], actions: [{ type: "hash_cookie", name: "lang" }] }],
|
||||
|
||||
@@ -4224,6 +4224,36 @@ sub vcl_backend_response {
|
||||
<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="cacheGuideCdnTitle">Cloudflare and Akamai technical Cookie template</h3>
|
||||
<p data-i18n="cacheGuideCdnText">Only strip the Cookie header when every cookie is a known technical CDN cookie. Any session or unknown cookie, Authorization, private path or non-GET/HEAD method bypasses cache.</p>
|
||||
<pre><code>// Optional template: only shared/public content independent of these cookies.
|
||||
// Cloudflare: __cf_bm, cf_clearance, _cfuvid, __cfruid, __cfseq
|
||||
// Akamai: _abck, ak_bmsc, bm_sz, bm_sv
|
||||
// Security cookies can be needed for bot challenges; review before enabling.
|
||||
sub vcl_recv {
|
||||
if (req.method != "GET" && req.method != "HEAD") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.url ~ "^/(admin|api|auth|login|logout|panel|konto|dashboard)(/|[?]|$)") {
|
||||
return(pass);
|
||||
}
|
||||
if (req.http.Authorization) {
|
||||
return(pass);
|
||||
}
|
||||
// Match the complete Cookie header, not one cookie within it.
|
||||
if (req.http.Cookie ~ "^(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*(?:;[ \t]*(?:__cf_bm|cf_clearance|_cfuvid|__cfruid|__cfseq|_abck|ak_bmsc|bm_sz|bm_sv)=[^;]*)*$") {
|
||||
unset req.http.Cookie;
|
||||
}
|
||||
if (req.http.Cookie) {
|
||||
return(pass);
|
||||
}
|
||||
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="cacheGuideCdnWarning">Optional policy: some CDN challenge cookies are required at the origin. Verify public pages and the challenge flow before using this template. It does not override Cache-Control and Vary admission safeguards.</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>
|
||||
@@ -4245,6 +4275,7 @@ curl -sS -D - -o /dev/null \
|
||||
</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_SUPPORT_MATRIX.md" target="_blank" rel="noopener noreferrer" data-i18n="cacheGuideDocsMatrix">VCL support: implemented vs unsupported</a>
|
||||
<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>
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
const selected = scope(), options = [el("option", t("logAllVhosts"))];
|
||||
options[0].value = "*";
|
||||
for (const vhost of data.vhosts || []) {
|
||||
const option = el("option", `${vhost.id} / ${(vhost.hosts || []).join(", ")}`);
|
||||
option.value = vhost.id; options.push(option);
|
||||
const option = el("option", vhost.label || `${vhost.id} / ${(vhost.hosts || []).join(", ")}`);
|
||||
option.value = vhost.id; option.title = vhost.id; options.push(option);
|
||||
}
|
||||
$("traffic-scope").replaceChildren(...options);
|
||||
$("traffic-scope").value = options.some(option => option.value === selected) ? selected : "*";
|
||||
@@ -117,12 +117,22 @@
|
||||
loading = true;
|
||||
try {
|
||||
const base = `/api/traffic?vhost=${encodeURIComponent(scope())}`;
|
||||
let data = await api(staticData ? `${base}&view=live` : base, { signal });
|
||||
if (staticData && data.revision !== staticRevision) {
|
||||
let data;
|
||||
try {
|
||||
data = await api(staticData ? `${base}&view=live` : base, { signal });
|
||||
} catch (error) {
|
||||
// Labels are inventory-derived. If the selected publication
|
||||
// vanished, fall back to All rather than polling a stale ID.
|
||||
if (error?.status !== 404 || scope() === "*") throw error;
|
||||
$("traffic-scope").value = "*";
|
||||
staticData = null; staticRevision = null;
|
||||
data = await api("/api/traffic?vhost=*", { signal });
|
||||
}
|
||||
if (staticData && (data.revision !== staticRevision || data.catalog_version !== staticData.catalog_version)) {
|
||||
data = await api(base, { signal });
|
||||
}
|
||||
if (Array.isArray(data.vhosts)) {
|
||||
staticData = { vhosts: data.vhosts };
|
||||
staticData = { vhosts: data.vhosts, catalog_version: data.catalog_version };
|
||||
staticRevision = data.revision;
|
||||
} else if (staticData) {
|
||||
data = { ...staticData, ...data };
|
||||
|
||||
Reference in new issue
Block a user