[GH-ISSUE #4907] [Bug]: A blank page appears when subscribing in the URL reverse proxy. #3430

Closed
opened 2026-10-31 20:32:23 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @ckun52880 on GitHub (Jun 4, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4907

Describe the bug

Subscriptions show a blank page in the URL reverse proxy. Nginx is listening on the domain a.example.com. When the a.example.com domain does not have a specific URL, it will be forwarded to a self-built disguised web service. However, when setting up a subscription in the 3x-ui web panel and enabling the reverse proxy URL in the subscription, opening the sub actually shows a blank page, while JSON and CLASH can run normally. I created a new domain b.example.com, and when listening entirely on port 2096, the sub works normally.

How to reproduce the problem

The following is the nginx configuration a.example.com

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    
    proxy_set_header X-Forwarded-Host $host;                      
    proxy_set_header X-Real-IP $remote_addr;                       

    proxy_set_header X-Forwarded-Proto $scheme;                  
    proxy_set_header Host $http_host;                                 
    proxy_set_header Range $http_range;                                
    proxy_set_header If-Range $http_if_range;                         

    proxy_redirect off;                                            

    proxy_pass http://127.0.0.1:5212;                                 
    client_max_body_size 20000m;
        }

location ^~ /sub/aa/ {   
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
    proxy_set_header X-Forwarded-Host $host;                       
    proxy_set_header X-Real-IP $remote_addr;                       

    proxy_set_header X-Forwarded-Proto $scheme;                   
    proxy_set_header Host $http_host;                                 
    proxy_set_header Range $http_range;                           
    proxy_set_header If-Range $http_if_range;                       
    
    proxy_http_version 1.1;                                          
    proxy_set_header Upgrade $http_upgrade;                           
    proxy_set_header Connection "upgrade";                           

    proxy_redirect off;                                            

    proxy_pass http://127.0.0.1:2096/sub/bb/;      
}

The following is the nginx configuration b.example.com

location / {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;    
    proxy_set_header X-Forwarded-Host $host;                      
    proxy_set_header X-Real-IP $remote_addr;                       

    proxy_set_header X-Forwarded-Proto $scheme;                  
    proxy_set_header Host $http_host;                                 
    proxy_set_header Range $http_range;                                
    proxy_set_header If-Range $http_if_range;                         

    proxy_redirect off;                                            

    proxy_pass http://127.0.0.1:2096;                                 

        }

location ^~ /sub/aa/ {   
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;  
    proxy_set_header X-Forwarded-Host $host;                       
    proxy_set_header X-Real-IP $remote_addr;                       

    proxy_set_header X-Forwarded-Proto $scheme;                   
    proxy_set_header Host $http_host;                                 
    proxy_set_header Range $http_range;                           
    proxy_set_header If-Range $http_if_range;                       
    
    proxy_http_version 1.1;                                          
    proxy_set_header Upgrade $http_upgrade;                           
    proxy_set_header Connection "upgrade";                           

    proxy_redirect off;                                            

    proxy_pass http://127.0.0.1:2096/sub/bb/;      
}

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

v3.2.7

Xray-core version

v26.6.1

How did you install 3x-ui?

install.sh script

Operating system

Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-112-generic x86_64)

Which parts of the panel are affected?

Subscription (share links / Clash / JSON)

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

Yes — Nginx

Before submitting

  • I searched existing issues and this bug has not been reported.
  • I am running the latest released version of 3x-ui (or have verified the bug still exists on it).
  • This bug report is written in English.
  • I have redacted any sensitive data (tokens, real domains, client UUIDs).
Originally created by @ckun52880 on GitHub (Jun 4, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/4907 ### Describe the bug Subscriptions show a blank page in the URL reverse proxy. Nginx is listening on the domain a.example.com. When the a.example.com domain does not have a specific URL, it will be forwarded to a self-built disguised web service. However, when setting up a subscription in the 3x-ui web panel and enabling the reverse proxy URL in the subscription, opening the sub actually shows a blank page, while JSON and CLASH can run normally. I created a new domain b.example.com, and when listening entirely on port 2096, the sub works normally. ### How to reproduce the problem The following is the nginx configuration a.example.com ``` location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_redirect off; proxy_pass http://127.0.0.1:5212; client_max_body_size 20000m; } location ^~ /sub/aa/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; proxy_pass http://127.0.0.1:2096/sub/bb/; } ``` The following is the nginx configuration b.example.com ``` location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_redirect off; proxy_pass http://127.0.0.1:2096; } location ^~ /sub/aa/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header Range $http_range; proxy_set_header If-Range $http_if_range; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; proxy_pass http://127.0.0.1:2096/sub/bb/; } ``` ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version v3.2.7 ### Xray-core version v26.6.1 ### How did you install 3x-ui? install.sh script ### Operating system Ubuntu 22.04.4 LTS (GNU/Linux 5.15.0-112-generic x86_64) ### Which parts of the panel are affected? Subscription (share links / Clash / JSON) ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? Yes — Nginx ### Before submitting - [x] I searched [existing issues](../issues?q=is%3Aissue) and this bug has not been reported. - [x] I am running the latest released version of 3x-ui (or have verified the bug still exists on it). - [x] This bug report is written in English. - [x] I have redacted any sensitive data (tokens, real domains, client UUIDs).
bsakaguchi 2026-10-31 20:32:23 +07:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@github-actions[bot] commented on GitHub (Jun 4, 2026):

Root Cause

This is a reverse-proxy asset routing problem specific to the HTML subscription page (the React SPA served when a browser opens the sub URL with Accept: text/html).

Here is what happens step by step:

  1. Nginx receives GET /sub/aa/<TOKEN> with Accept: text/html from the browser.
  2. Nginx rewrites the path and forwards it to http://127.0.0.1:2096/sub/bb/<TOKEN>.
  3. The sub server detects the browser Accept header and returns subpage.html — the React SPA.
  4. The SPA needs to load its JS/CSS bundle. The sub server sets its internal base_path to its configured SubPath (e.g. /sub/bb/), and rewrites all asset src/href tags in subpage.html to /sub/bb/assets/… (see sub/sub.go lines 94–101 and sub/subController.go lines 188–192).
  5. The browser now requests https://a.example.com/sub/bb/assets/index-xxx.js.
  6. Nginx has no location block for /sub/bb/ — it only has one for /sub/aa/. The request falls through to the catch-all location / block and is forwarded to port 5212 (your disguised web service) instead of port 2096. The assets return unrelated content → blank React page.

JSON and CLASH subscriptions work because they return plain text/plain / application/yaml data with no external asset references.


Fix (simplest)

Align the 3x-ui SubPath with what nginx exposes publicly, so no path rewrite is needed.

Step 1 — Change the Sub Path in the panel settings:

Go to Panel Settings → Subscription → Sub Path and change it from /sub/bb/ to /sub/aa/.

After saving, restart the service:

systemctl restart x-ui

Step 2 — Update the nginx proxy_pass to remove the path rewrite:

location ^~ /sub/aa/ {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";

    proxy_redirect off;

    # Path now matches — no rewrite needed
    proxy_pass http://127.0.0.1:2096/sub/aa/;
}

With both sides using /sub/aa/, the base_path inside the HTML will be /sub/aa/, the assets will be requested from /sub/aa/assets/…, and that path is proxied correctly to port 2096.


Alternative Fix (keep the path rewrite)

If you need to keep /sub/aa/ → /sub/bb/ for other reasons, add an extra nginx location to also proxy the asset path to the sub server:

location ^~ /sub/bb/assets/ {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://127.0.0.1:2096/sub/bb/assets/;
}

Place this block before your catch-all location / block.

<!-- gh-comment-id:4622028066 --> @github-actions[bot] commented on GitHub (Jun 4, 2026): ## Root Cause This is a reverse-proxy asset routing problem specific to the **HTML subscription page** (the React SPA served when a browser opens the sub URL with `Accept: text/html`). Here is what happens step by step: 1. Nginx receives `GET /sub/aa/<TOKEN>` with `Accept: text/html` from the browser. 2. Nginx rewrites the path and forwards it to `http://127.0.0.1:2096/sub/bb/<TOKEN>`. 3. The sub server detects the browser `Accept` header and returns `subpage.html` — the React SPA. 4. The SPA needs to load its JS/CSS bundle. The sub server sets its internal `base_path` to its configured **SubPath** (e.g. `/sub/bb/`), and rewrites all asset `src`/`href` tags in `subpage.html` to `/sub/bb/assets/…` (see `sub/sub.go` lines 94–101 and `sub/subController.go` lines 188–192). 5. The browser now requests `https://a.example.com/sub/bb/assets/index-xxx.js`. 6. Nginx has **no location block for `/sub/bb/`** — it only has one for `/sub/aa/`. The request falls through to the catch-all `location /` block and is forwarded to **port 5212** (your disguised web service) instead of port 2096. The assets return unrelated content → blank React page. JSON and CLASH subscriptions work because they return plain `text/plain` / `application/yaml` data with no external asset references. --- ## Fix (simplest) Align the 3x-ui **SubPath** with what nginx exposes publicly, so no path rewrite is needed. **Step 1 — Change the Sub Path in the panel settings:** Go to **Panel Settings → Subscription → Sub Path** and change it from `/sub/bb/` to `/sub/aa/`. After saving, restart the service: ```bash systemctl restart x-ui ``` **Step 2 — Update the nginx `proxy_pass` to remove the path rewrite:** ```nginx location ^~ /sub/aa/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_redirect off; # Path now matches — no rewrite needed proxy_pass http://127.0.0.1:2096/sub/aa/; } ``` With both sides using `/sub/aa/`, the `base_path` inside the HTML will be `/sub/aa/`, the assets will be requested from `/sub/aa/assets/…`, and that path is proxied correctly to port 2096. --- ## Alternative Fix (keep the path rewrite) If you need to keep `/sub/aa/` → `/sub/bb/` for other reasons, add an extra nginx location to also proxy the asset path to the sub server: ```nginx location ^~ /sub/bb/assets/ { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://127.0.0.1:2096/sub/bb/assets/; } ``` Place this block **before** your catch-all `location /` block.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MHSanaei/3x-ui#3430
No description provided.