Fix subscription page white screen: restore prefix location for deep paths

Regex location only matches single-segment paths (subscription IDs).
Deep asset paths like /sub_path/static/js/main.js fall through to the
prefix location /sub_path/ which proxies them to x-ui sub port normally.
Nginx regex > prefix priority ensures Clash UA detection still works for IDs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ivan Razin
2026-06-24 14:24:06 +03:00
co-authored by Claude Sonnet 4.6
parent 4b5c56785c
commit f294cf4b6e
+13 -5
View File
@@ -307,18 +307,26 @@ EOF
# Shared proxy locations for xray inbounds (included by both vhosts)
cat > /etc/nginx/snippets/includes.conf <<EOF
#Subscription (plain/encode) — Clash/Mihomo clients get per-client dynamic clash.yaml
# rewrite...last is safe inside if; proxy_pass with URI is in a separate internal location
location = /${sub_path} {
#Subscription — prefix location covers all sub-paths (assets, JS, etc.)
location /${sub_path}/ {
if (\$hack = 1) { return 404; }
if (\$is_clash_client = 1) { rewrite ^ /__clash_api last; }
proxy_redirect off;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:${sub_port};
}
location ~ ^/${sub_path}/(?<clash_sub_id>[^/]*)$ {
location = /${sub_path} {
if (\$hack = 1) { return 404; }
proxy_redirect off;
proxy_set_header Host \$host;
proxy_set_header X-Real-IP \$remote_addr;
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
proxy_pass https://127.0.0.1:${sub_port};
}
# Regex takes priority over prefix: catches subscription IDs (one-level deep)
# and routes Clash/Mihomo clients to dynamic clash.yaml generator
location ~ ^/${sub_path}/(?<clash_sub_id>[^/]+)$ {
if (\$hack = 1) { return 404; }
if (\$is_clash_client = 1) { rewrite ^ /__clash_api?sub_id=\$clash_sub_id last; }
proxy_redirect off;