v0.42.2_fix2
This commit is contained in:
1 parent
25148f26eb
commit
a75893d428
16 files changed
+301
-66
No files matched your search
@@ -123,6 +123,7 @@ fn admin_vhosts_javascript() -> &'static str {
|
||||
static ASSET: std::sync::LazyLock<String> = std::sync::LazyLock::new(|| {
|
||||
[
|
||||
"(() => {",
|
||||
include_str!("web/vhosts/source.js"),
|
||||
include_str!("web/vhosts/core.js"),
|
||||
include_str!("web/vhosts/protocol.js"),
|
||||
include_str!("web/vhosts/health.js"),
|
||||
|
||||
@@ -1667,4 +1667,101 @@ html[data-interface-icons="true"] :is(button, a, summary)>svg.ui-icon {
|
||||
flex: 0 0 auto;
|
||||
max-width: none;
|
||||
overflow: visible;
|
||||
}
|
||||
}
|
||||
/* Shared FastCGI profiles: keep the help text and controls inside the dialog,
|
||||
including at high UI zoom and with long translated labels. */
|
||||
#php-fpm-profiles-dialog {
|
||||
width: calc(min(860px, 100vw - 24px) / var(--ui-scale, 1));
|
||||
}
|
||||
|
||||
#php-fpm-profiles-dialog .location-help-content {
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-dialog .php-profiles-description {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
margin: 0 0 12px;
|
||||
white-space: normal;
|
||||
overflow-wrap: anywhere;
|
||||
line-height: 1.55;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list {
|
||||
display: grid;
|
||||
min-width: 0;
|
||||
gap: 8px;
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list > .fastcgi-profile-card {
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-summary {
|
||||
cursor: pointer;
|
||||
padding: 4px 6px;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-title {
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-handler {
|
||||
display: inline-block;
|
||||
margin-inline-start: 12px;
|
||||
padding: 1px 6px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--rp-radius-control, 3px);
|
||||
color: var(--muted);
|
||||
font-size: 10px;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list details[open] > .fastcgi-profile-summary {
|
||||
margin-bottom: 12px;
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 12px;
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor > label {
|
||||
display: grid;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
grid-row: auto;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor > label > :is(input, select, textarea) {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor .fastcgi-profile-php-heading {
|
||||
padding-top: 6px;
|
||||
border-top: 1px solid var(--line);
|
||||
}
|
||||
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor .fastcgi-profile-php-heading strong {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.fastcgi-php-only-local[hidden],
|
||||
#php-fpm-profiles-list .fastcgi-php-only[hidden],
|
||||
#php-fpm-profiles-list .fastcgi-profile-php-heading[hidden] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
@media (max-width: 650px) {
|
||||
#php-fpm-profiles-list .fastcgi-profile-editor {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
}
|
||||
@@ -4989,9 +4989,9 @@ 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">FastCGI / PHP-FPM source and endpoint</h3>
|
||||
<h3 data-i18n="webServicePhpSourceSection">FastCGI configuration source and endpoint</h3>
|
||||
<div class="vh-grid">
|
||||
<label class="vh-wide"><span data-i18n="phpProfileSelect">PHP-FPM configuration
|
||||
<label class="vh-wide"><span data-i18n="phpProfileSelect">FastCGI configuration
|
||||
source</span>
|
||||
<select id="web-service-php-profile">
|
||||
<option value="" data-i18n="phpProfileLocal">Local configuration</option>
|
||||
@@ -5094,7 +5094,7 @@ curl -sS -D - -o /dev/null \
|
||||
class="fine" data-i18n="phpHintConcurrency">Max simultaneous PHP requests for this
|
||||
service;
|
||||
e.g. 64. Exhaustion returns 503 (1–4096).</small></label>
|
||||
<label><span data-i18n="webServicePhpBodyLimit">PHP request body limit (bytes, 0 =
|
||||
<label><span data-i18n="webServicePhpBodyLimit">FastCGI request body limit (bytes, 0 =
|
||||
unlimited)</span><input id="web-service-php-body-limit" min="0" max="8589934592"
|
||||
step="1" type="number" /><small class="fine" data-i18n="phpHintBodyLimit">Bytes, not
|
||||
MB: 67108864 =
|
||||
@@ -5104,7 +5104,7 @@ curl -sS -D - -o /dev/null \
|
||||
step="1" type="number" /><small class="fine" data-i18n="phpHintHeaderLimit">Max PHP
|
||||
response-header size in bytes; default
|
||||
65536 = 64 KiB (4096–1048576).</small></label>
|
||||
<label><span data-i18n="webServicePhpStderrLimit">Max PHP-FPM stderr log bytes</span><input
|
||||
<label><span data-i18n="webServicePhpStderrLimit">Max FastCGI stderr log bytes</span><input
|
||||
id="web-service-php-stderr-limit" min="0" max="65536" step="1"
|
||||
type="number" /><small class="fine" data-i18n="phpHintStderrLimit">Max FastCGI
|
||||
STDERR bytes kept per request; e.g.
|
||||
@@ -5112,7 +5112,7 @@ curl -sS -D - -o /dev/null \
|
||||
</div>
|
||||
</section>
|
||||
<section class="vh-wide vh-setting-section web-service-setting-section">
|
||||
<h3 data-i18n="webServicePhpOverridesSection">FastCGI and php.ini overrides</h3>
|
||||
<h3 data-i18n="webServicePhpOverridesSection">FastCGI parameters and PHP-FPM options</h3>
|
||||
<div class="vh-grid">
|
||||
<label class="vh-wide"><span data-i18n="webServicePhpCustomParams">Custom FastCGI
|
||||
parameters</span><textarea id="web-service-php-custom-params" maxlength="65536"
|
||||
@@ -5121,7 +5121,7 @@ curl -sS -D - -o /dev/null \
|
||||
data-i18n="webServicePhpCustomParamsHelp">One NAME = value entry per line.
|
||||
Static trusted values only; core CGI, HTTP_* and PHP_* control names are
|
||||
reserved. Example: APP_ENV = production; no variable interpolation.</small></label>
|
||||
<label class="vh-wide"><span data-i18n="webServicePhpValues">PHP INI overrides
|
||||
<label class="vh-wide fastcgi-php-only-local"><span data-i18n="webServicePhpValues">PHP INI overrides
|
||||
(PHP_VALUE)</span><textarea id="web-service-php-values" maxlength="65536" rows="6"
|
||||
spellcheck="false"
|
||||
placeholder="memory_limit = 256M upload_max_filesize = 64M post_max_size = 64M"></textarea><small
|
||||
@@ -5130,7 +5130,7 @@ curl -sS -D - -o /dev/null \
|
||||
Examples: memory_limit = 256M, upload_max_filesize = 64M, post_max_size = 64M,
|
||||
max_execution_time = 30. Use PHP_ADMIN_VALUE for operator-only
|
||||
settings.</small></label>
|
||||
<label class="vh-wide"><span data-i18n="phpProfileAdminValues">PHP administrator INI
|
||||
<label class="vh-wide fastcgi-php-only-local"><span data-i18n="phpProfileAdminValues">PHP administrator INI
|
||||
overrides
|
||||
(PHP_ADMIN_VALUE)</span><textarea id="web-service-php-admin-values"
|
||||
maxlength="65536" rows="6" spellcheck="false"
|
||||
@@ -5179,7 +5179,7 @@ curl -sS -D - -o /dev/null \
|
||||
<button type="button" class="outline" id="php-fpm-profiles-close" data-i18n="close">Close</button>
|
||||
</div>
|
||||
<div class="card location-help-content">
|
||||
<p class="fine" data-i18n="phpProfileDescription">Expand a profile to edit it. Changes are saved immediately
|
||||
<p class="fine php-profiles-description" data-i18n="phpProfileDescription">Expand a profile to edit it. Changes are saved immediately
|
||||
and shared by every attached Web Service.</p>
|
||||
<div id="php-fpm-profiles-list"></div>
|
||||
<button type="button" class="outline" id="php-fpm-profile-add" data-i18n="phpProfileAdd">Add
|
||||
|
||||
@@ -616,12 +616,12 @@ function collect() {
|
||||
const bindingSelection = readBindings();
|
||||
const mainSourceType = str("source-type");
|
||||
const mainFallbackTarget = str("main-error-target"), mainFallbackStatuses = lines(str("main-error-statuses")).map(value => Number(value));
|
||||
const needsProxy = mainSourceType === "reverse_proxy" || paths.some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy");
|
||||
const needsProxy = vhostRequiresProxy({ source: { type: mainSourceType }, routes: paths });
|
||||
if (!bindingSelection.length) throw new Error(t("vhListenerRequired"));
|
||||
if (needsProxy && !members.length) throw new Error(t("vhBackendRequired"));
|
||||
if (yes("www-redirect") && !str("www-redirect-target")) throw new Error(t("vhWwwNoHosts"));
|
||||
if (mainSourceType === "web_server" && !str("source-web-service")) throw new Error(t("webServiceRequired"));
|
||||
if (paths.some(route => !route.response && route.source?.type === "web_server" && !route.source.web_service_id)) throw new Error(t("webServiceRequired"));
|
||||
if (paths.some(route => !route.response && !route.redirect && route.source?.type === "web_server" && !route.source.web_service_id)) throw new Error(t("webServiceRequired"));
|
||||
if (yes("force-ssl")) {
|
||||
const tlsPorts = new Set(); let tlsSelected = false, httpSelected = false;
|
||||
for (const id of bindingSelection) {
|
||||
|
||||
@@ -602,7 +602,7 @@ function render() {
|
||||
if (!initialized) load(defaults(), [], false);
|
||||
const config = envelope.config;
|
||||
const configuredHasProxySource = (config.vhosts || []).some(vhost =>
|
||||
vhost.source?.type !== "web_server" || (vhost.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy")
|
||||
vhostRequiresProxy(vhost)
|
||||
);
|
||||
const diagnosticsCard = $("backend-diagnostics-card");
|
||||
diagnosticsCard?.classList.toggle("is-no-proxy", !configuredHasProxySource);
|
||||
@@ -677,7 +677,7 @@ function render() {
|
||||
["vhAclProfile", v.acl_profile_id ? ((config.acl_profiles || []).find(profile => profile.id === v.acl_profile_id)?.name || v.acl_profile_id) : t("vhAclProfileNone")],
|
||||
["cache", v.cache?.enabled === true ? t("enabled") : v.cache?.enabled === false ? t("notEnabled") : t("inherit")],
|
||||
["vhBackendPool", v.source?.type === "web_server"
|
||||
? ((v.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy") && (v.backends || []).length
|
||||
? ((v.routes || []).some(locationRequiresProxy) && (v.backends || []).length
|
||||
? `${t("webServer")} + ${(v.backends || []).length}`
|
||||
: t("webServer"))
|
||||
: `${(v.backends || []).length}`],
|
||||
@@ -701,7 +701,7 @@ function render() {
|
||||
box.append(live);
|
||||
const chart = el("div", undefined, "vhost-chart"); const chartHead = el("div", undefined, "vhost-chart-head"); chartHead.append(text("span", "vhLifetimeChart", "small-label")); const chartValue = el("span", "-", "fine"); chartValue.dataset.chartValueFor = v.id; chartHead.append(chartValue); chart.append(chartHead);
|
||||
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"); svg.setAttribute("viewBox", "0 0 320 54"); svg.setAttribute("preserveAspectRatio", "none"); svg.dataset.chartFor = v.id; svg.setAttribute("aria-label", t("vhLifetimeChart")); const polyline = document.createElementNS("http://www.w3.org/2000/svg", "polyline"); polyline.setAttribute("class", "vhost-chart-line"); svg.append(polyline); chart.append(svg); box.append(chart);
|
||||
const hasProxySource = v.source?.type !== "web_server" || (v.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy");
|
||||
const hasProxySource = vhostRequiresProxy(v);
|
||||
if (hasProxySource) {
|
||||
const health = el("p", t("vhHealthEmpty"), "vh-health-summary"); health.dataset.healthFor = v.id; box.append(health);
|
||||
}
|
||||
@@ -839,7 +839,7 @@ function renderStatus(status) {
|
||||
for (const [id, vhost] of configuredVhosts) {
|
||||
const existing = aggregate.get(id) || {};
|
||||
const metrics = status.vhost_metrics?.[id];
|
||||
const hasProxySource = vhost.source?.type !== "web_server" || (vhost.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy");
|
||||
const hasProxySource = vhostRequiresProxy(vhost);
|
||||
const disabled = vhost.enabled === false;
|
||||
aggregate.set(id, {
|
||||
...existing,
|
||||
@@ -858,7 +858,7 @@ function renderStatus(status) {
|
||||
}
|
||||
for (const key of vhostTrafficHistory.keys()) if (!seenVhostTraffic.has(key)) vhostTrafficHistory.delete(key);
|
||||
const hasConfiguredProxySource = [...configuredVhosts.values()].some(vhost =>
|
||||
vhost.source?.type !== "web_server" || (vhost.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy")
|
||||
vhostRequiresProxy(vhost)
|
||||
);
|
||||
if (buildPoolRows) $("pool-rows").replaceChildren(...rows); else overviewViewsPending = true;
|
||||
renderBackendOverview(overviewItems, hasConfiguredProxySource, status, false);
|
||||
@@ -900,7 +900,7 @@ function renderStatus(status) {
|
||||
}
|
||||
}
|
||||
const editingVhost = editing ? configuredVhosts.get(editing) : null;
|
||||
const editingHasProxy = editingVhost && (editingVhost.source?.type !== "web_server" || (editingVhost.routes || []).some(route => !route.response && (route.source?.type || "reverse_proxy") === "reverse_proxy"));
|
||||
const editingHasProxy = editingVhost && vhostRequiresProxy(editingVhost);
|
||||
$("vhost-health-live").hidden = !!editingVhost && !editingHasProxy;
|
||||
$("vhost-health-live").textContent = editing ? (editingHasProxy ? (summaries.get(editing) || t("vhHealthEmpty")) : "") : t("vhNewHealthHint");
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
// A local redirect or response terminates in RustProxy and never connects to an
|
||||
// upstream. Disabled custom locations do not create a live backend dependency.
|
||||
// Keep these checks aligned with Vhost::validate and config/routing.rs.
|
||||
function locationRequiresProxy(route) {
|
||||
return route.enabled !== false
|
||||
&& !route.response
|
||||
&& !route.redirect
|
||||
&& (route.source?.type || "reverse_proxy") === "reverse_proxy";
|
||||
}
|
||||
function vhostRequiresProxy(vhost) {
|
||||
return (vhost.source?.type || "reverse_proxy") === "reverse_proxy"
|
||||
|| (vhost.routes || []).some(locationRequiresProxy);
|
||||
}
|
||||
@@ -12,8 +12,8 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
|
||||
const profileFields = [
|
||||
["enabled", "webServicePhpEnabled", "checkbox"],
|
||||
["endpoint", "webServicePhpEndpoint", "text"],
|
||||
["handler", "webServiceFastCgiHandler", "select"],
|
||||
["endpoint", "webServicePhpEndpoint", "text"],
|
||||
["script_name_prefix", "webServiceFastCgiScriptPrefix", "text"],
|
||||
["extensions", "webServicePhpExtensions", "text"],
|
||||
["path_info", "webServicePhpPathInfo", "checkbox"],
|
||||
@@ -41,10 +41,13 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
};
|
||||
|
||||
function profileEditor(profile, creating = false) {
|
||||
const details = document.createElement("details"); details.className = "card";
|
||||
const details = document.createElement("details"); details.className = "card fastcgi-profile-card";
|
||||
if (creating) details.open = true;
|
||||
const summary = el("summary", profile.name || profile.id || t("phpProfileNew"));
|
||||
const editor = document.createElement("form"); editor.className = "vh-grid"; editor.noValidate = true;
|
||||
const summary = el("summary", undefined, "fastcgi-profile-summary");
|
||||
const title = el("span", profile.name || profile.id || t("phpProfileNew"), "fastcgi-profile-title");
|
||||
const kindBadge = el("span", "", "fastcgi-profile-handler");
|
||||
summary.append(title, kindBadge);
|
||||
const editor = document.createElement("form"); editor.className = "vh-grid fastcgi-profile-editor"; editor.noValidate = true;
|
||||
const namedInput = (key, value, readonly = false) => {
|
||||
const wrapper = el("label");
|
||||
wrapper.append(el("span", t(key)));
|
||||
@@ -54,10 +57,21 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
const idInput = namedInput("phpProfileId", profile.id, !creating);
|
||||
const nameInput = namedInput("phpProfileName", profile.name);
|
||||
const controls = {};
|
||||
const phpOnlyWrappers = [];
|
||||
let phpOnlySection;
|
||||
for (const [key, label, kind, min, max] of profileFields) {
|
||||
if (key === "php_values") {
|
||||
phpOnlySection = el("div", undefined, "vh-wide fastcgi-profile-php-heading");
|
||||
phpOnlySection.append(el("strong", t("phpProfilePhpOnlySection")));
|
||||
editor.append(phpOnlySection);
|
||||
}
|
||||
const toggle = kind === "checkbox";
|
||||
const wrapper = toggle ? el("div", undefined, "php-switch-row vh-wide") : el("label");
|
||||
if (!toggle && kind === "textarea") wrapper.className = "vh-wide";
|
||||
if (key === "php_values" || key === "php_admin_values") {
|
||||
wrapper.classList.add("fastcgi-php-only");
|
||||
phpOnlyWrappers.push(wrapper);
|
||||
}
|
||||
const labelEl = toggle ? el("label", undefined, "check php-switch-label") : wrapper;
|
||||
const input = document.createElement(kind === "textarea" ? "textarea" : kind === "select" ? "select" : "input");
|
||||
if (kind !== "textarea" && kind !== "select") input.type = kind;
|
||||
@@ -94,6 +108,18 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
editor.append(wrapper); controls[key] = input;
|
||||
}
|
||||
const handlerSelector = controls.handler;
|
||||
const syncHandler = () => {
|
||||
const kind = handlerSelector.value;
|
||||
const phpFpm = kind === "php_fpm";
|
||||
const caption = { php_fpm: "PHP-FPM", fcgiwrap: "fcgiwrap", fastcgi: "FastCGI" };
|
||||
kindBadge.textContent = caption[kind] || "FastCGI";
|
||||
for (const wrapper of phpOnlyWrappers) wrapper.hidden = !phpFpm;
|
||||
phpOnlySection.hidden = !phpFpm;
|
||||
controls.php_values.disabled = !phpFpm;
|
||||
controls.php_admin_values.disabled = !phpFpm;
|
||||
controls.endpoint.placeholder = kind === "fcgiwrap" ? "unix:/run/fcgiwrap.socket" : kind === "fastcgi" ? "tcp:127.0.0.1:9001" : "unix:/run/php/php-fpm.sock";
|
||||
controls.extensions.placeholder = kind === "fcgiwrap" ? "cgi, pl" : kind === "fastcgi" ? "fcgi" : "php, phtml";
|
||||
};
|
||||
handlerSelector.addEventListener("change", () => {
|
||||
const kind = handlerSelector.value;
|
||||
if (kind !== "php_fpm" && controls.extensions.value.trim().toLowerCase() === "php") {
|
||||
@@ -104,15 +130,12 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
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 = "";
|
||||
if (kind === "php_fpm" && controls.endpoint.value === "unix:/run/fcgiwrap.socket") {
|
||||
controls.endpoint.value = "unix:/run/php/php-fpm.sock";
|
||||
}
|
||||
controls.php_values.disabled = kind !== "php_fpm";
|
||||
controls.php_admin_values.disabled = kind !== "php_fpm";
|
||||
syncHandler();
|
||||
});
|
||||
controls.php_values.disabled = handlerSelector.value !== "php_fpm";
|
||||
controls.php_admin_values.disabled = handlerSelector.value !== "php_fpm";
|
||||
syncHandler();
|
||||
const actions = el("div", undefined, "form-actions vh-wide");
|
||||
const save = el("button", t("apply"), "primary"); save.type = "submit";
|
||||
actions.append(save);
|
||||
@@ -138,8 +161,13 @@ window.rustProxyPhpProfiles = ({ defaults, mapLines, lines, parseFastCgiParams,
|
||||
kind === "checkbox" ? controls[key].checked : kind === "number" ? Number(controls[key].value) :
|
||||
key === "extensions" ? lines(controls[key].value).map(item => item.replace(/^\./, "").toLowerCase()) :
|
||||
key === "custom_params" ? parseFastCgiParams(controls[key].value) :
|
||||
key === "php_values" || key === "php_admin_values" ? parsePhpValues(controls[key].value) : controls[key].value.trim()
|
||||
key === "php_values" || key === "php_admin_values" ?
|
||||
handlerSelector.value === "php_fpm" ? parsePhpValues(controls[key].value) : {} : controls[key].value.trim()
|
||||
]));
|
||||
if (php.handler !== "php_fpm") {
|
||||
php.php_values = {};
|
||||
php.php_admin_values = {};
|
||||
}
|
||||
validatePhpCustomData(php.custom_params, php.php_values, php.php_admin_values);
|
||||
const next = structuredClone(envelope.config.php_fpm_profiles || []);
|
||||
if (next.some(item => item.id === id && (creating || item.id !== profile.id))) throw new Error(t("phpProfileDuplicate"));
|
||||
|
||||
@@ -171,7 +171,11 @@
|
||||
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";
|
||||
const selectedProfile = attached
|
||||
? (envelope?.config.php_fpm_profiles || []).find(profile => profile.id === $("web-service-php-profile").value)
|
||||
: null;
|
||||
const phpFpm = (selectedProfile?.php?.handler || $("web-service-php-handler").value) === "php_fpm";
|
||||
for (const item of document.querySelectorAll(".fastcgi-php-only-local")) item.hidden = !phpFpm;
|
||||
$("web-service-php-values").disabled = !enabled || attached || !phpFpm;
|
||||
$("web-service-php-admin-values").disabled = !enabled || attached || !phpFpm;
|
||||
|
||||
@@ -560,8 +564,8 @@
|
||||
max_response_header_bytes: Number($("web-service-php-header-limit").value || 65536),
|
||||
stderr_log_bytes: Number($("web-service-php-stderr-limit").value || 0),
|
||||
custom_params: parseFastCgiParams($("web-service-php-custom-params").value),
|
||||
php_values: parsePhpValues($("web-service-php-values").value),
|
||||
php_admin_values: parsePhpValues($("web-service-php-admin-values").value)
|
||||
php_values: $("web-service-php-handler").value === "php_fpm" ? parsePhpValues($("web-service-php-values").value) : {},
|
||||
php_admin_values: $("web-service-php-handler").value === "php_fpm" ? parsePhpValues($("web-service-php-admin-values").value) : {}
|
||||
}
|
||||
};
|
||||
validatePhpCustomData(item.php.custom_params, item.php.php_values, item.php.php_admin_values);
|
||||
@@ -595,9 +599,8 @@
|
||||
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 = "";
|
||||
if (kind === "php_fpm" && endpoint.value === "unix:/run/fcgiwrap.socket") {
|
||||
endpoint.value = "unix:/run/php/php-fpm.sock";
|
||||
}
|
||||
syncPhp();
|
||||
});
|
||||
|
||||
@@ -327,3 +327,41 @@ mod timing_allow_origin_tests {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mod local_web_service_redirect_tests {
|
||||
use super::Vhost;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn web_service_with_local_redirect_does_not_require_proxy_backend() {
|
||||
let mut host: Vhost = serde_json::from_value(json!({
|
||||
"id": "web-with-redirect",
|
||||
"frontend": { "hosts": ["example.test"], "listener_ids": ["http"] },
|
||||
"source": { "type": "web_server", "web_service_id": "site" },
|
||||
"routes": [
|
||||
{
|
||||
"id": "root-redirect", "match_type": "exact", "path_prefix": "/",
|
||||
"source": { "type": "reverse_proxy" },
|
||||
"redirect": { "status": 302, "target": "https://example.test/app/" }
|
||||
},
|
||||
{
|
||||
"id": "local-error", "match_type": "exact", "path_prefix": "/maintenance",
|
||||
"source": { "type": "reverse_proxy" },
|
||||
"response": { "status": 503, "body": "Maintenance" }
|
||||
}
|
||||
]
|
||||
}))
|
||||
.unwrap();
|
||||
assert!(host.validate().is_ok(), "local actions require no backend");
|
||||
|
||||
host.routes.push(serde_json::from_value(json!({
|
||||
"id": "unused-proxy", "path_prefix": "/disabled/", "enabled": false,
|
||||
"source": { "type": "reverse_proxy" }
|
||||
})).unwrap());
|
||||
assert!(host.validate().is_ok(), "disabled proxy route needs no backend");
|
||||
|
||||
host.routes.last_mut().unwrap().enabled = true;
|
||||
assert!(host.validate().unwrap_err().to_string().contains("backend"),
|
||||
"an active reverse-proxy route still requires a backend");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user