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:
co-authored by
Claude Sonnet 4.6
parent
4b5c56785c
commit
f294cf4b6e
+13
-5
@@ -307,18 +307,26 @@ EOF
|
|||||||
|
|
||||||
# Shared proxy locations for xray inbounds (included by both vhosts)
|
# Shared proxy locations for xray inbounds (included by both vhosts)
|
||||||
cat > /etc/nginx/snippets/includes.conf <<EOF
|
cat > /etc/nginx/snippets/includes.conf <<EOF
|
||||||
#Subscription (plain/encode) — Clash/Mihomo clients get per-client dynamic clash.yaml
|
#Subscription — prefix location covers all sub-paths (assets, JS, etc.)
|
||||||
# rewrite...last is safe inside if; proxy_pass with URI is in a separate internal location
|
location /${sub_path}/ {
|
||||||
location = /${sub_path} {
|
|
||||||
if (\$hack = 1) { return 404; }
|
if (\$hack = 1) { return 404; }
|
||||||
if (\$is_clash_client = 1) { rewrite ^ /__clash_api last; }
|
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
proxy_set_header Host \$host;
|
proxy_set_header Host \$host;
|
||||||
proxy_set_header X-Real-IP \$remote_addr;
|
proxy_set_header X-Real-IP \$remote_addr;
|
||||||
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
|
||||||
proxy_pass https://127.0.0.1:${sub_port};
|
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 (\$hack = 1) { return 404; }
|
||||||
if (\$is_clash_client = 1) { rewrite ^ /__clash_api?sub_id=\$clash_sub_id last; }
|
if (\$is_clash_client = 1) { rewrite ^ /__clash_api?sub_id=\$clash_sub_id last; }
|
||||||
proxy_redirect off;
|
proxy_redirect off;
|
||||||
|
|||||||
Reference in New Issue
Block a user