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

+24 -15
View File
@@ -921,7 +921,7 @@
data-i18n-placeholder="webServiceSearchPlaceholder" id="web-service-search"
type="search" />
<button class="outline" data-i18n="phpProfileToolbar"
id="web-service-php-profiles-open" type="button">PHP-FPM profiles</button>
id="web-service-php-profiles-open" type="button">FastCGI profiles</button>
<button class="outline" data-i18n="webServiceNew" id="web-service-new"
type="button">New Web Service</button>
</div>
@@ -4864,6 +4864,7 @@ curl -sS -D - -o /dev/null \
checked /><span data-i18n="webServiceHtaccessRecursive">Scan subdirectories</span></label>
<label class="check"><input class="switch" id="web-service-htaccess-strict" type="checkbox" /><span
data-i18n="webServiceHtaccessStrict">Strict unsupported-directive mode</span></label>
<p class="fine vh-wide" data-i18n="webServiceHtaccessStrictHelp">When Strict is off, unsupported non-security directives are skipped and logged as warnings. Legacy Order/Allow/Deny with all, IP and CIDR are enforced; unsupported access-control rules still block Apply.</p>
<div class="vh-wide"><button class="outline" id="web-service-htaccess-help"
data-i18n="webServiceHtaccessDocs" type="button">Compatibility documentation</button></div>
<p class="fine vh-wide" data-i18n="webServiceHtaccessHelp">RustProxy compiles a bounded
@@ -4982,7 +4983,7 @@ curl -sS -D - -o /dev/null \
</div>
<div class="vh-grid web-service-page" data-web-service-page="php" hidden>
<section class="vh-wide vh-setting-section web-service-setting-section">
<h3 data-i18n="webServicePhpSourceSection">PHP-FPM source and endpoint</h3>
<h3 data-i18n="webServicePhpSourceSection">FastCGI / PHP-FPM source and endpoint</h3>
<div class="vh-grid">
<label class="vh-wide"><span data-i18n="phpProfileSelect">PHP-FPM configuration
source</span>
@@ -4994,7 +4995,7 @@ curl -sS -D - -o /dev/null \
Profile changes apply to all attached Web Services.</small>
</label>
<div class="vh-wide"><button type="button" class="outline" id="web-service-php-profiles"
data-i18n="phpProfileManage">Manage PHP-FPM profiles</button></div>
data-i18n="phpProfileManage">Manage FastCGI profiles</button></div>
<div class="vh-wide php-switch-row"><label class="check php-switch-label"><input
class="switch" id="web-service-php-enabled" type="checkbox" /><span
data-i18n="webServicePhpEnabled">Enable PHP-FPM / FastCGI</span></label>
@@ -5009,13 +5010,24 @@ curl -sS -D - -o /dev/null \
</div>
</details>
</div>
<label class="vh-wide"><span data-i18n="webServicePhpEndpoint">PHP-FPM endpoint</span><input
<label class="vh-wide"><span data-i18n="webServiceFastCgiHandler">FastCGI handler</span>
<select id="web-service-php-handler">
<option value="php_fpm">PHP-FPM</option>
<option value="fcgiwrap">fcgiwrap (CGI)</option>
<option value="fastcgi">FastCGI responder</option>
</select><small class="fine" data-i18n="webServiceFastCgiHandlerHelp">Select PHP-FPM for PHP, fcgiwrap for CGI programs or FastCGI for compatible responders.</small>
</label>
<label class="vh-wide"><span data-i18n="webServiceFastCgiScriptPrefix">Public SCRIPT_NAME prefix</span>
<input id="web-service-php-script-prefix" maxlength="256" placeholder="/app/cgi-bin" />
<small class="fine" data-i18n="webServiceFastCgiScriptPrefixHelp">Set the public URL prefix removed by the Vhost path rewrite, for example /app/cgi-bin. Leave empty without a rewrite.</small>
</label>
<label class="vh-wide"><span data-i18n="webServicePhpEndpoint">FastCGI endpoint</span><input
id="web-service-php-endpoint" maxlength="512"
placeholder="unix:/run/php/php-fpm.sock" /><small class="fine"
data-i18n="webServicePhpEndpointHelp">Unix: unix:/run/php/php-fpm.sock. TCP:
tcp:127.0.0.1:9000 or tcp:[::1]:9000. TCP is intentionally limited to loopback
addresses.</small></label>
<label><span data-i18n="webServicePhpExtensions">PHP extensions</span><input
<label><span data-i18n="webServicePhpExtensions">Executable extensions (PHP or CGI)</span><input
id="web-service-php-extensions" maxlength="512" placeholder="php, phtml" /><small
class="fine" data-i18n="phpHintExtensions">Comma-separated extensions without dots
(e.g.
@@ -5125,10 +5137,7 @@ curl -sS -D - -o /dev/null \
<div class="vh-wide form-actions"><button class="outline"
data-i18n="webServicePhpDocsButton" id="web-service-php-help" type="button">FastCGI
syntax and safety</button></div>
<p class="fine vh-wide" data-i18n="webServicePhpHelp">RustProxy speaks FastCGI directly to a
long-running PHP-FPM pool. PHP is not spawned per request and PHP source is never served
when
PHP handling is selected.</p>
<p class="fine vh-wide" data-i18n="webServicePhpHelp">RustProxy connects to PHP-FPM, fcgiwrap or other compatible FastCGI responders. Select executable extensions, configure a Unix or loopback TCP endpoint, and optionally set the public SCRIPT_NAME prefix when Vhost locations strip a URL prefix. Script source is never served statically for protected executable extensions.</p>
</div>
</section>
</div>
@@ -5160,7 +5169,7 @@ curl -sS -D - -o /dev/null \
</dialog>
<dialog aria-labelledby="php-profiles-title" class="vhost-dialog location-help-dialog" id="php-fpm-profiles-dialog">
<div class="window-heading">
<h2 id="php-profiles-title" data-i18n="phpProfileTitle">Shared PHP-FPM profiles</h2>
<h2 id="php-profiles-title" data-i18n="phpProfileTitle">Shared FastCGI profiles</h2>
<button type="button" class="outline" id="php-fpm-profiles-close" data-i18n="close">Close</button>
</div>
<div class="card location-help-content">
@@ -5207,11 +5216,11 @@ RewriteRule . /index.php [L]</code></pre>
128 files, depth 16, 128 KiB per file and 1 MiB total.</p>
<h3 data-i18n="webServiceHtaccessDocsUnsupportedTitle">Not Apache-complete</h3>
<p data-i18n="webServiceHtaccessDocsUnsupported">ErrorDocument, SetEnvIf, Redirect/RedirectMatch and
FallbackResource are not implemented in this compatibility layer. General Files/FilesMatch, unsupported
authentication/authorization directives, non-PHP handlers and SetHandler are rejected even when Strict
mode is off because silently ignoring them could weaken access control or expose source.
.htaccess/.htpasswd files are always blocked from HTTP delivery. Other unsupported non-security
directives are logged and ignored unless Strict mode is enabled.</p>
FallbackResource are not implemented. Order/Allow/Deny with all, IP or CIDR (IPv4/IPv6) are supported
and enforced. General Files/FilesMatch, unsupported authentication/authorization and hostname access
directives, non-PHP handlers and SetHandler are rejected even with Strict off: ignoring them may expose
protected content. .htaccess/.htpasswd are never served over HTTP. Other unsupported non-security
directives are logged and skipped with Strict off.</p>
<p class="fine" data-i18n="webServiceHtaccessDocsSecurity">Vhost/location ACL, authentication, error pages
and response rules still remain authoritative. .htaccess cannot escape the document root, select an
arbitrary FastCGI socket or override protected framing headers.</p>
+33 -3
View File
@@ -13,6 +13,8 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
const profileFields = [
["enabled", "webServicePhpEnabled", "checkbox"],
["endpoint", "webServicePhpEndpoint", "text"],
["handler", "webServiceFastCgiHandler", "select"],
["script_name_prefix", "webServiceFastCgiScriptPrefix", "text"],
["extensions", "webServicePhpExtensions", "text"],
["path_info", "webServicePhpPathInfo", "checkbox"],
["pass_authorization", "webServicePhpPassAuthorization", "checkbox"],
@@ -29,6 +31,7 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
const helpKeys = {
enabled: "phpHintEnabled", path_info: "phpHintPathInfo", endpoint: "webServicePhpDocsEndpoint",
handler: "webServiceFastCgiHandlerHelp", script_name_prefix: "webServiceFastCgiScriptPrefixHelp",
extensions: "phpHintExtensions", pass_authorization: "phpHintPassAuthorization",
connect_timeout_ms: "phpHintConnectTimeout", request_timeout_ms: "phpHintRequestTimeout",
max_concurrent_requests: "phpHintConcurrency", max_request_body_bytes: "phpHintBodyLimit",
@@ -56,18 +59,25 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
const wrapper = toggle ? el("div", undefined, "php-switch-row vh-wide") : el("label");
if (!toggle && kind === "textarea") wrapper.className = "vh-wide";
const labelEl = toggle ? el("label", undefined, "check php-switch-label") : wrapper;
const input = document.createElement(kind === "textarea" ? "textarea" : "input");
if (kind !== "textarea") input.type = kind;
const input = document.createElement(kind === "textarea" ? "textarea" : kind === "select" ? "select" : "input");
if (kind !== "textarea" && kind !== "select") input.type = kind;
if (kind === "select") {
for (const [value, label] of [["php_fpm", "PHP-FPM"], ["fcgiwrap", "fcgiwrap (CGI)"], ["fastcgi", "FastCGI responder"]]) {
const option = el("option", label); option.value = value; input.append(option);
}
}
if (toggle) input.classList.add("switch");
const caption = el("span", t(label));
if (toggle) labelEl.append(input, caption); else labelEl.append(caption, input);
if (toggle) input.checked = profile.php?.[key] === true;
else if (kind === "textarea") { input.rows = 4; input.maxLength = 65536; input.value = mapLines(profile.php?.[key]); }
else if (key === "extensions") input.value = (profile.php?.extensions || ["php"]).join(", ");
else if (key === "handler") input.value = profile.php?.handler || "php_fpm";
else input.value = profile.php?.[key] ?? "";
if (kind === "number") { input.min = min; input.max = max; input.step = 1; input.required = true; }
if (key === "endpoint") { input.required = true; input.maxLength = 512; input.placeholder = "unix:/run/php/php-fpm.sock"; }
if (key === "extensions") input.placeholder = "php, phtml";
if (key === "script_name_prefix") { input.maxLength = 256; input.placeholder = "/app/cgi-bin"; }
if (key === "extensions") input.placeholder = "php, cgi, fcgi";
if (key === "custom_params") input.placeholder = "APP_ENV = production\nAPP_DEBUG = 0";
if (key === "php_values") input.placeholder = "memory_limit = 256M\npost_max_size = 64M";
if (key === "php_admin_values") input.placeholder = "open_basedir = /var/www/webmail/:/tmp/";
@@ -83,6 +93,26 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
}
editor.append(wrapper); controls[key] = input;
}
const handlerSelector = controls.handler;
handlerSelector.addEventListener("change", () => {
const kind = handlerSelector.value;
if (kind !== "php_fpm" && controls.extensions.value.trim().toLowerCase() === "php") {
controls.extensions.value = kind === "fcgiwrap" ? "cgi" : "fcgi";
} else if (kind === "php_fpm" && ["cgi", "fcgi"].includes(controls.extensions.value.trim().toLowerCase())) {
controls.extensions.value = "php";
}
if (kind === "fcgiwrap" && controls.endpoint.value === "unix:/run/php/php-fpm.sock") {
controls.endpoint.value = "unix:/run/fcgiwrap.socket";
}
if (kind !== "php_fpm") {
controls.php_values.value = "";
controls.php_admin_values.value = "";
}
controls.php_values.disabled = kind !== "php_fpm";
controls.php_admin_values.disabled = kind !== "php_fpm";
});
controls.php_values.disabled = handlerSelector.value !== "php_fpm";
controls.php_admin_values.disabled = handlerSelector.value !== "php_fpm";
const actions = el("div", undefined, "form-actions vh-wide");
const save = el("button", t("apply"), "primary"); save.type = "submit";
actions.append(save);
+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);