Patch: enforce panel HTTPS, fix set -e SIGPIPE abort, README one-liner
- x-ui-patch.sh: detect when the panel has no TLS cert (empty webCertFile) and enable HTTPS the way the main installer does — symlink the Let's Encrypt cert into /root/cert/$domain and register it via `x-ui cert`. Without this the panel serves plain HTTP and every proxy_pass https://127.0.0.1:panel_port (including the diag SSO bridge) fails. - x-ui-patch.sh: guard the `tr </dev/urandom | head -c N` random generators with `|| true`. head closes the pipe, tr dies with SIGPIPE (141), and under `pipefail`+`errexit` that intermittently aborts the whole script. - README: replace the two-step patch download/run block with a single curl|bash one-liner (also drops a stale wget filename mismatch). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ddc7deef31
commit
65e095133f
@@ -42,16 +42,10 @@ bash x-ui-latest.sh -install y -subdomain panel.example.com -reality_domain r.ex
|
|||||||
---
|
---
|
||||||
## Патч
|
## Патч
|
||||||
|
|
||||||
**Шаг 1 — скачать скрипт**
|
Применить текущие фиксы к существующей установке (без изменений БД):
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
wget -qO x-ui-latest.sh https://raw.githubusercontent.com/mozaroc/3x-ui-pro/main/x-ui-patch.sh
|
bash <(curl -fsSL https://raw.githubusercontent.com/mozaroc/3x-ui-pro/main/x-ui-patch.sh)
|
||||||
```
|
|
||||||
|
|
||||||
**Шаг 2 — запустить**
|
|
||||||
|
|
||||||
```bash
|
|
||||||
bash x-ui-patch.sh
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|||||||
+33
-3
@@ -71,6 +71,36 @@ done
|
|||||||
printf " domain = %s\n" "$domain"
|
printf " domain = %s\n" "$domain"
|
||||||
printf " reality_domain = %s\n" "$reality_domain"
|
printf " reality_domain = %s\n" "$reality_domain"
|
||||||
|
|
||||||
|
# ── ensure the panel is served over HTTPS ─────────────────────────────────────
|
||||||
|
# The panel vhost and the diag SSO bridge both proxy_pass https://127.0.0.1:panel_port.
|
||||||
|
# If the panel has no TLS cert configured it answers plain HTTP and every one of
|
||||||
|
# those proxy_pass calls fails (502 / SSL handshake error, diag never loads).
|
||||||
|
# Mirror the main installer: symlink the Let's Encrypt cert into /root/cert and
|
||||||
|
# register it with `x-ui cert`.
|
||||||
|
web_cert=$(db "SELECT value FROM settings WHERE key='webCertFile';")
|
||||||
|
if [[ -z "$web_cert" ]]; then
|
||||||
|
blue "Panel has no TLS cert configured — enabling HTTPS..."
|
||||||
|
if [[ -d "/etc/letsencrypt/live/${domain}" ]]; then
|
||||||
|
mkdir -p "/root/cert/${domain}"
|
||||||
|
chmod 755 /root/cert/* 2>/dev/null || true
|
||||||
|
ln -sf "/etc/letsencrypt/live/${domain}/fullchain.pem" "/root/cert/${domain}/fullchain.pem"
|
||||||
|
ln -sf "/etc/letsencrypt/live/${domain}/privkey.pem" "/root/cert/${domain}/privkey.pem"
|
||||||
|
if [[ -x /usr/local/x-ui/x-ui ]]; then
|
||||||
|
/usr/local/x-ui/x-ui cert \
|
||||||
|
-webCert "/root/cert/${domain}/fullchain.pem" \
|
||||||
|
-webCertKey "/root/cert/${domain}/privkey.pem"
|
||||||
|
systemctl restart x-ui 2>/dev/null || x-ui restart 2>/dev/null || true
|
||||||
|
green "Panel HTTPS enabled."
|
||||||
|
else
|
||||||
|
red "x-ui binary not found at /usr/local/x-ui/x-ui — cannot set panel cert."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
red "No Let's Encrypt cert for ${domain} at /etc/letsencrypt/live/${domain} — cannot enable panel HTTPS."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
blue "Panel TLS cert already configured."
|
||||||
|
fi
|
||||||
|
|
||||||
# ── detect xhttp_path ─────────────────────────────────────────────────────────
|
# ── detect xhttp_path ─────────────────────────────────────────────────────────
|
||||||
xhttp_path=""
|
xhttp_path=""
|
||||||
# 1. from existing includes.conf
|
# 1. from existing includes.conf
|
||||||
@@ -87,7 +117,7 @@ if [[ -z "$xhttp_path" ]]; then
|
|||||||
fi
|
fi
|
||||||
# 3. generate new
|
# 3. generate new
|
||||||
if [[ -z "$xhttp_path" ]]; then
|
if [[ -z "$xhttp_path" ]]; then
|
||||||
xhttp_path=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 10)
|
xhttp_path=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 10 || true)
|
||||||
blue "xhttp_path generated: $xhttp_path"
|
blue "xhttp_path generated: $xhttp_path"
|
||||||
else
|
else
|
||||||
blue "xhttp_path detected: $xhttp_path"
|
blue "xhttp_path detected: $xhttp_path"
|
||||||
@@ -103,7 +133,7 @@ done
|
|||||||
if [[ -n "$diag_path" ]]; then
|
if [[ -n "$diag_path" ]]; then
|
||||||
blue "diag_path reused: $diag_path"
|
blue "diag_path reused: $diag_path"
|
||||||
else
|
else
|
||||||
diag_path="/net-$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 12)/"
|
diag_path="/net-$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 12 || true)/"
|
||||||
blue "diag_path generated: $diag_path"
|
blue "diag_path generated: $diag_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -117,7 +147,7 @@ done
|
|||||||
if [[ -n "$diag_token" ]]; then
|
if [[ -n "$diag_token" ]]; then
|
||||||
blue "diag_token reused"
|
blue "diag_token reused"
|
||||||
else
|
else
|
||||||
diag_token=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16)
|
diag_token=$(tr -dc 'a-zA-Z0-9' </dev/urandom | head -c 16 || true)
|
||||||
blue "diag_token generated"
|
blue "diag_token generated"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user