This commit is contained in:
Mateusz Gruszczyński committed 2026-11-26 11:02:46 +01:00
1 parent aa0a271a1c
commit f38a2b9e5e
38 files changed
+1098 -160

No files matched your search

+57 -4
View File
@@ -1,6 +1,7 @@
"use strict";
(() => {
let editing = null, dirty = false;
let htaccessWarnings = {}, htaccessWarningsRevision = null, htaccessWarningsLoading = false;
const form = $("web-service-form"), dialog = $("web-service-dialog");
function syncRootPermissions() {
window.rustProxyPermissions?.render($("web-service-permissions"), { kind: "web", paths: [$("web-service-root").value] });
@@ -54,7 +55,7 @@
const reservedFastCgiParams = new Set([
"REQUEST_METHOD", "SCRIPT_FILENAME", "SCRIPT_NAME", "QUERY_STRING", "REQUEST_URI", "DOCUMENT_ROOT",
"SERVER_PROTOCOL", "SERVER_NAME", "SERVER_PORT", "REMOTE_ADDR", "REMOTE_PORT", "HTTPS",
"SERVER_PROTOCOL", "SERVER_NAME", "SERVER_PORT", "REMOTE_ADDR", "REMOTE_PORT", "REMOTE_USER", "AUTH_USER", "HTTPS",
"GATEWAY_INTERFACE", "SERVER_SOFTWARE", "REDIRECT_STATUS", "CONTENT_TYPE", "CONTENT_LENGTH",
"PATH_INFO", "PATH_TRANSLATED", "PHP_VALUE", "PHP_ADMIN_VALUE"
]);
@@ -170,13 +171,17 @@
const attached = !!$("web-service-php-profile").value;
const enabled = $("web-service-php-enabled").checked;
$("web-service-php-enabled").disabled = attached;
const phpFpm = $("web-service-php-handler").value === "php_fpm";
$("web-service-php-values").disabled = !enabled || attached || !phpFpm;
$("web-service-php-admin-values").disabled = !enabled || attached || !phpFpm;
for (const id of [
"web-service-php-endpoint", "web-service-php-extensions", "web-service-php-connect-timeout",
"web-service-php-endpoint", "web-service-php-handler", "web-service-php-script-prefix",
"web-service-php-extensions", "web-service-php-connect-timeout",
"web-service-php-request-timeout", "web-service-php-concurrency", "web-service-php-pass-authorization",
"web-service-php-path-info",
"web-service-php-body-limit", "web-service-php-header-limit", "web-service-php-stderr-limit",
"web-service-php-custom-params", "web-service-php-values", "web-service-php-admin-values"
"web-service-php-custom-params"
]) $(id).disabled = !enabled || attached;
}
@@ -213,7 +218,8 @@
mime_types: {}, default_mime_type: "application/octet-stream", cache_control: null, cache_rules: [], response_headers: {},
try_files: [], rewrites: [], compression: { enabled: null, gzip: null, br: null, zstd: null, deflate: null }, precompressed: { enabled: false, brotli: true, gzip: true }, download_extensions: [],
symlink_policy: "deny", php_profile_id: null, php: {
enabled: false, path_info: false, extensions: ["php"], endpoint: "unix:/run/php/php-fpm.sock", connect_timeout_ms: 1000,
enabled: false, path_info: false, extensions: ["php"], endpoint: "unix:/run/php/php-fpm.sock",
handler: "php_fpm", script_name_prefix: "", connect_timeout_ms: 1000,
request_timeout_ms: 30000, max_concurrent_requests: 64, pass_authorization: true, max_request_body_bytes: 0,
max_response_header_bytes: 65536, stderr_log_bytes: 4096, custom_params: {}, php_values: {}, php_admin_values: {}
},
@@ -264,6 +270,8 @@
$("web-service-php-enabled").checked = item.php?.enabled === true;
$("web-service-php-path-info").checked = item.php?.path_info === true;
$("web-service-php-endpoint").value = item.php?.endpoint || "unix:/run/php/php-fpm.sock";
$("web-service-php-handler").value = ["php_fpm", "fcgiwrap", "fastcgi"].includes(item.php?.handler) ? item.php.handler : "php_fpm";
$("web-service-php-script-prefix").value = item.php?.script_name_prefix || "";
$("web-service-php-extensions").value = (item.php?.extensions || ["php"]).join(", ");
$("web-service-php-connect-timeout").value = item.php?.connect_timeout_ms ?? 1000;
$("web-service-php-request-timeout").value = item.php?.request_timeout_ms ?? 30000;
@@ -362,9 +370,23 @@
}
function closeEditor() { if (dirty) return window.rustProxyDrafts.dock("web-server"); clearEditor(); return true; }
async function loadHtaccessWarnings() {
if (htaccessWarningsLoading || !envelope || !authenticated) return;
htaccessWarningsLoading = true;
try {
const result = await api("/api/web-services/htaccess-warnings");
if (!envelope || result.revision !== envelope.revision) return;
htaccessWarnings = result.services || {};
htaccessWarningsRevision = result.revision;
if (currentPanel === "web-server") render();
} catch { /* The configuration remains available if diagnostics cannot be loaded. */ }
finally { htaccessWarningsLoading = false; }
}
function render() {
syncRootPermissions();
if (!envelope) return;
if (htaccessWarningsRevision !== envelope.revision && !htaccessWarningsLoading) void loadHtaccessWarnings();
const query = ($("web-service-search")?.value || "").trim().toLowerCase();
const services = (envelope.config.web_services || []).filter(service => !query || [service.id, service.name, service.document_root].join(" ").toLowerCase().includes(query));
const cards = services.map(service => {
@@ -402,6 +424,17 @@
item.append(el("span", t(key), "small-label"), el("b", value));
details.append(item);
}
// Show the real skipped directives from the active configuration, with
// file/line context. Security-related errors never appear here: they fail Apply.
const ignored = htaccessWarningsRevision === envelope.revision ? (htaccessWarnings[service.id]?.warnings || []) : [];
if (service.htaccess?.enabled && ignored.length) {
const details = el("details", undefined, "web-service-htaccess-warnings");
details.append(el("summary", `${t("webServiceHtaccessWarningsCount")}: ${ignored.length}`));
const lines = el("ul");
for (const warning of ignored.slice(0, 50)) lines.append(el("li", warning));
if (ignored.length > 50) lines.append(el("li", `+${ignored.length - 50}`));
details.append(lines); box.append(details);
}
const live = el("section", undefined, "www-service-panel");
const panel = el("div", undefined, "www-service-live"); panel.dataset.webLiveId = service.id;
@@ -517,6 +550,8 @@
path_info: $("web-service-php-path-info").checked,
extensions: lines($("web-service-php-extensions").value).map(value => value.replace(/^\./, "").toLowerCase()),
endpoint: $("web-service-php-endpoint").value.trim() || "unix:/run/php/php-fpm.sock",
handler: $("web-service-php-handler").value,
script_name_prefix: $("web-service-php-script-prefix").value.trim(),
connect_timeout_ms: Number($("web-service-php-connect-timeout").value || 1000),
request_timeout_ms: Number($("web-service-php-request-timeout").value || 30000),
max_concurrent_requests: Number($("web-service-php-concurrency").value || 64),
@@ -548,6 +583,24 @@
$("web-service-root").addEventListener("input", syncRootPermissions);
$("web-service-root").addEventListener("change", syncRootPermissions);
$("web-service-php-enabled").addEventListener("change", syncPhp);
$("web-service-php-handler").addEventListener("change", () => {
const kind = $("web-service-php-handler").value;
const extensions = $("web-service-php-extensions");
if (kind !== "php_fpm" && extensions.value.trim().toLowerCase() === "php") {
extensions.value = kind === "fcgiwrap" ? "cgi" : "fcgi";
} else if (kind === "php_fpm" && ["cgi", "fcgi"].includes(extensions.value.trim().toLowerCase())) {
extensions.value = "php";
}
const endpoint = $("web-service-php-endpoint");
if (kind === "fcgiwrap" && endpoint.value === "unix:/run/php/php-fpm.sock") {
endpoint.value = "unix:/run/fcgiwrap.socket";
}
if (kind !== "php_fpm") {
$("web-service-php-values").value = "";
$("web-service-php-admin-values").value = "";
}
syncPhp();
});
$("web-service-php-profile").addEventListener("change", syncPhp);
$("web-service-php-profiles").addEventListener("click", openProfiles);
$("web-service-php-profiles-open").addEventListener("click", openProfiles);