This commit is contained in:
Mateusz Gruszczyński committed 2026-11-26 08:50:30 +01:00
1 parent 167861fc16
commit aa0a271a1c
38 files changed
+3642 -1058

No files matched your search

+20 -12
View File
@@ -207,10 +207,12 @@ function load(value = defaults(), migrationIds = [], show = true) {
g = group("vhHeadersPreview"); headersPreviewControl = headersPreview(g);
g = group("vhBackendDiagnostics");
const diagnosticCards = el("div", undefined, "vh-wide hdr-cards"); g.append(diagnosticCards);
diagnosticCard(diagnosticCards, { name: "timing-headers", key: "vhTimingHeaders", checked: value.timing_headers === true, header: "Server-Timing", example: "proxy;dur=1.8, upstream;dur=12.4", help: "hdrCardTimingHelp", extra: body => {
field(body, "timing-header-names", "vhTimingHeaderNames", value.timing_header_names || "standard", "select", { values: [["standard", "vhTimingHeaderNamesStandard"], ["cdn", "vhTimingHeaderNamesCdn"], ["legacy", "vhTimingHeaderNamesLegacy"]] });
field(body, "timing-allow-origin", "vhTimingAllowOrigin", (value.timing_allow_origin || []).join(", "), "text", { maxLength: 2048 }).placeholder = "https://app.example.com";
} });
diagnosticCard(diagnosticCards, {
name: "timing-headers", key: "vhTimingHeaders", checked: value.timing_headers === true, header: "Server-Timing", example: "proxy;dur=1.8, upstream;dur=12.4", help: "hdrCardTimingHelp", extra: body => {
field(body, "timing-header-names", "vhTimingHeaderNames", value.timing_header_names || "standard", "select", { values: [["standard", "vhTimingHeaderNamesStandard"], ["cdn", "vhTimingHeaderNamesCdn"], ["legacy", "vhTimingHeaderNamesLegacy"]] });
field(body, "timing-allow-origin", "vhTimingAllowOrigin", (value.timing_allow_origin || []).join(", "), "text", { maxLength: 2048 }).placeholder = "https://app.example.com";
}
});
diagnosticCard(diagnosticCards, { name: "backend-header", key: "vhBackendHeader", checked: value.backend_header === true, header: "X-Rust-Proxy-Backend", example: `${value.id || "vhost"}/${(value.backends || [])[0]?.id || "origin-1"}`, help: "hdrCardBackendHelp" });
diagnosticCard(diagnosticCards, { name: "backend-timing-header", key: "vhBackendTimingHeader", checked: value.backend_timing_header === true, header: "X-RustProxy-Backend-Time", example: "12.40ms", help: "hdrCardBackendTimeHelp" });
note(g, "vhBackendDiagnosticsHelp");
@@ -306,8 +308,10 @@ function load(value = defaults(), migrationIds = [], show = true) {
profileBox.append(multiWarning); aclFields.append(profileBox); note(aclFields, "vhAclProfileHelp");
const inlineAclFields = subsection(g, "vhIpAccess");
aclControl = aclEditor(inlineAclFields, value.acl, () => { if (aclControl) read("acl").value = JSON.stringify(aclControl.read(), null, 2); });
const aclJson = jsonDrawer(inlineAclFields, { name: "acl", titleKey: "vhAclJson", helpKey: "vhAclJsonHelp", value: value.acl ?? null, maxLength: 32768, validate: validateInlineAcl, apply: data => aclControl.set(data) });
aclControl = aclEditor(inlineAclFields, value.acl, () => { if (aclControl) { aclJson.target.value = JSON.stringify(aclControl.read(), null, 2); aclJson.refresh(); changed(); } });
note(inlineAclFields, "vhInlineAclHelp");
inlineAclFields.append(aclJson.node);
const methodFields = subsection(g, "vhTrafficMethodsSection");
field(methodFields, "method-mode", "vhMethodMode", methodPolicy.mode || "off", "select", { values: [["off", "vhOff"], ["allow", "locationMethodAllow"], ["block", "locationMethodBlock"]] });
@@ -360,14 +364,13 @@ function load(value = defaults(), migrationIds = [], show = true) {
field(uaBlockingFields, "ua-block-enabled", "vhUaBlockEnabled", uaBlock.enabled === true, "checkbox", { switch: true });
field(uaBlockingFields, "ua-block-patterns", "vhUaBlockPatterns", (uaBlock.patterns || []).join("\n"), "textarea", { rows: 4, maxLength: 32768 });
note(uaBlockingFields, "vhUaBlockHelp");
g = group("vhAdvanced", true); field(g, "paths", "vhPaths", JSON.stringify(value.routes || [], null, 2), "textarea", { rows: 5, maxLength: 131072 });
field(g, "acl", "vhAcl", JSON.stringify(value.acl ?? null, null, 2), "textarea", { rows: 5, maxLength: 32768 });
field(g, "headers", "vhHeaders", JSON.stringify(value.headers || {}, null, 2), "textarea", { rows: 5, maxLength: 65536 });
g = group("vhLocations");
field(g, "main-error-target", "vhErrorFallbackTarget", value.error_fallback?.target || "", "text", { maxLength: 64, pattern: "[A-Za-z0-9_\\-]{0,64}" });
field(g, "main-error-statuses", "vhErrorFallbackStatuses", (value.error_fallback?.statuses || [404]).join(", "), "text", { maxLength: 64 });
note(g, "vhErrorFallbackHelp");
locationsReader = locationsEditor(g, value.routes || []);
const pathsJson = jsonDrawer(g, { name: "paths", titleKey: "vhLocationsJson", helpKey: "vhLocationsJsonHelp", value: value.routes || [], maxLength: 131072, validate: validateLocations, apply: data => locationsReader.set(data) });
locationsReader = locationsEditor(g, value.routes || [], () => { changed(); pathsJson.refresh(); });
g.append(pathsJson.node);
g = group("vhSsl");
const certificateRow = el("div", undefined, "vh-wide vh-certificate-select-row"); g.append(certificateRow);
const selector = field(certificateRow, "certificate-id", "vhCertificate", value.certificate_id || "", "select");
@@ -578,7 +581,10 @@ function load(value = defaults(), migrationIds = [], show = true) {
};
transformEnabled.addEventListener("change", syncTransform); customTransformExtensions.addEventListener("change", syncTransform); syncTransform();
note(transformOptions, "vhTransformHelp");
g = group("vhHeaders"); g.parentElement.classList.add("hdr-rules-anchor"); vhostHeadersControl = headerEditors(g, value.headers || {});
g = group("vhHeaders"); g.parentElement.classList.add("hdr-rules-anchor");
const headersJson = jsonDrawer(g, { name: "headers", titleKey: "vhHeadersJson", helpKey: "vhHeadersJsonHelp", value: value.headers || {}, maxLength: 65536, validate: validateHeaders, apply: data => vhostHeadersControl.set(data) });
vhostHeadersControl = headerEditors(g, value.headers || {}, headersJson.target, () => { changed(); headersJson.refresh(); });
g.append(headersJson.node);
g = group("policyTitle"); vhostPolicyEditor = window.rustProxyPolicy.create({ value: value.policy || {}, scope: "vhost", onChange: changed }); g.append(vhostPolicyEditor.node);
g = group("vhPages"); g.classList.add("vh-pages-grid"); pagesEditor = window.rustProxyPages.vhostEditor(g, value.pages || {});
initTabs(); dirty = false; if (latestStatus) renderStatus(latestStatus); if (show && !dialog.open) dialog.showModal();
@@ -657,12 +663,14 @@ function collect() {
authentication: selectedAuthentication().provider === "none" ? null : selectedAuthentication(),
tinyauth: { enabled: selectedAuthentication().provider === "tinyauth" && selectedAuthentication().method === "forward_auth", url: str("auth-url"), login_url: str("auth-login"), allow_private: yes("auth-private"), redirect_forbidden: yes("auth-redirect-forbidden"), connect_timeout_seconds: num("auth-connect"), timeout_seconds: num("auth-timeout"), request_headers: lines(str("auth-request-headers")), response_headers: lines(str("auth-response-headers")), address_allowlist: lines(str("auth-allowlist")), tls_ca_pem: nullable("auth-ca") },
authelia: readForwardProvider("authelia"), authentik: readForwardProvider("authentik"),
oidc: { enabled: selectedAuthentication().method === "oidc", issuer_url: str("oidc-issuer"), backend_url: str("oidc-backend"),
oidc: {
enabled: selectedAuthentication().method === "oidc", issuer_url: str("oidc-issuer"), backend_url: str("oidc-backend"),
redirect_url: str("oidc-redirect"), client_id: str("oidc-client"),
client_secret: str("oidc-secret"), session_secret: str("oidc-session"), scopes: str("oidc-scopes"),
allow_private: yes("oidc-private"), address_allowlist: lines(str("oidc-allowlist")),
tls_ca_pem: nullable("oidc-ca"), connect_timeout_seconds: num("oidc-connect"),
timeout_seconds: num("oidc-timeout"), session_ttl_seconds: num("oidc-ttl") },
timeout_seconds: num("oidc-timeout"), session_ttl_seconds: num("oidc-ttl")
},
backends: members, routes: paths, acl, headers, policy: vhostPolicyEditor ? vhostPolicyEditor.read() : {},
load_balancing: {
algorithm: str("algorithm"), ...(vhostBalancingControl?.hash() ? { hash: vhostBalancingControl.hash() } : {}), slow_start_seconds: num("slow-start"), keepalive: { enabled: yes("keepalive"), idle_timeout_seconds: num("idle-timeout"), max_idle_per_host: num("max-idle"), tcp_keepalive_seconds: num("tcp-keepalive"), pool_recycle_requests: num("pool-recycle-requests"), pool_recycle_seconds: num("pool-recycle-seconds"), http1_max_buffer_bytes: num("http1-max-buffer") },