[GH-ISSUE #6942] [Bug]: Panel does not support HTTP/2, returns 502 when Cloudflare HTTP/2 to Origin is enabled #4592

Open
opened 2026-10-31 20:40:44 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @daohuosuo on GitHub (Oct 26, 2026).
Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6942

Describe the bug

hen using Cloudflare as a frontend proxy with HTTP/2 to Origin enabled (communication between Cloudflare and the origin server over HTTP/2), accessing the 3x-ui panel directly returns 502 Bad Gateway.

How to reproduce the problem

  1. Deploy 3x-ui, panel listens on 127.0.0.1:2053, base path /3xui/
  2. Nginx reverse proxy, listen on 443 ssl http2 with standard WebSocket Upgrade headers (Upgrade, Connection, Host, X-Forwarded-For)
  3. Enable Cloudflare HTTP/2 to Origin (HTTP/2 for visitors remains enabled)
  4. Access domain/3xui/ via browser → 502 error, panel fails to load, real-time log WebSocket handshake fails
  5. Disable Cloudflare HTTP/2 to Origin → Panel and WebSocket work normally

Expected behavior

No response

Actual behavior

No response

Relevant logs


Screenshots

No response

3x-ui version

3.11.0

Xray-core version

No response

How did you install 3x-ui?

Docker / Docker Compose

Operating system

Ubuntu 24.04

Which parts of the panel are affected?

No response

Browser (only if it is a UI bug)

No response

Is the panel behind a reverse proxy or CDN?

None

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 @daohuosuo on GitHub (Oct 26, 2026). Original GitHub issue: https://github.com/MHSanaei/3x-ui/issues/6942 ### Describe the bug hen using Cloudflare as a frontend proxy with `HTTP/2 to Origin` enabled (communication between Cloudflare and the origin server over HTTP/2), accessing the 3x-ui panel directly returns 502 Bad Gateway. ### How to reproduce the problem 1. Deploy 3x-ui, panel listens on `127.0.0.1:2053`, base path `/3xui/` 2. Nginx reverse proxy, listen on 443 ssl http2 with standard WebSocket Upgrade headers (Upgrade, Connection, Host, X-Forwarded-For) 3. Enable Cloudflare **HTTP/2 to Origin** (HTTP/2 for visitors remains enabled) 4. Access `domain/3xui/` via browser → 502 error, panel fails to load, real-time log WebSocket handshake fails 5. Disable Cloudflare `HTTP/2 to Origin` → Panel and WebSocket work normally ### Expected behavior _No response_ ### Actual behavior _No response_ ### Relevant logs ```shell ``` ### Screenshots _No response_ ### 3x-ui version 3.11.0 ### Xray-core version _No response_ ### How did you install 3x-ui? Docker / Docker Compose ### Operating system Ubuntu 24.04 ### Which parts of the panel are affected? _No response_ ### Browser (only if it is a UI bug) _No response_ ### Is the panel behind a reverse proxy or CDN? None ### 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).
Author
Owner

@github-actions[bot] commented on GitHub (Oct 26, 2026):

The panel isn't part of the HTTP/2 connection in your setup, so I don't think the panel's HTTP/2 support is what causes this 502. Cloudflare's "HTTP/2 to Origin" setting controls the connection from Cloudflare to Nginx. Nginx then opens its own separate connection to 127.0.0.1:2053. To find out which of those two connections fails, I need the logs listed at the end.

Why the panel's protocol doesn't matter here

  • proxy_pass in Nginx talks to its upstream over HTTP/1.x only (proxy_http_version takes 1.0 or 1.1). This is true whatever Cloudflare uses to reach Nginx. The panel only ever sees HTTP/1.1 from Nginx.
  • You're right that the panel's own listener doesn't offer HTTP/2. When the panel handles TLS itself, it builds its TLS config without an ALPN list (internal/web/web.go:612-614):
    c := &tls.Config{
        Certificates: []tls.Certificate{cert},
    }
    
    So it only negotiates HTTP/1.1. That only matters when Cloudflare connects straight to the panel port. In your setup Cloudflare connects to Nginx on 443.
  • So the 502 comes from one of the two connections. Either Cloudflare can't complete HTTP/2 with Nginx, or Nginx gets a bad answer from the panel. In the second case the problem would also show up with "HTTP/2 to Origin" turned off, and you say it doesn't. That points at the Cloudflare ↔ Nginx connection. This is my inference; I can't confirm it without your logs. One more inference: the panel's live updates use WebSockets. Over HTTP/2, a WebSocket needs a special extension (RFC 8441, "extended CONNECT"), and Nginx may not support it. If so, the WebSocket handshake would fail on that same connection.

Please send these, as text:

  1. The 502 page itself: is it a Cloudflare-branded error page (if so, which one: "502 Bad Gateway" or "Error 520/521/525…"?), or a plain nginx page?
  2. The lines in Nginx's error.log (often /var/log/nginx/error.log) from the moment you load domain/3xui/ with HTTP/2 to Origin enabled.
  3. Your Nginx version (nginx -V) and the full server { listen 443 ... } block, with the domain redacted.
  4. Whether Nginx runs on the host or in a container. The form says you installed with Docker, but 127.0.0.1:2053 is only reachable from Nginx if both share a network namespace (for example network_mode: host).

Also, the form says "Is the panel behind a reverse proxy or CDN? → None", but your steps describe Cloudflare in front of Nginx. I've taken the steps as correct.

Verdict: Insufficient information
Severity: N/A
Confidence: Medium
Root cause: Not established. The panel only receives HTTP/1.x from Nginx's proxy_pass. Its own TLS listener offers no h2 ALPN (internal/web/web.go:612-614), but that hop isn't used in this setup. The failure most likely sits between Cloudflare and Nginx (inference).
Same class: None found
Already fixed: Not applicable
Duplicate of: None
Evidence: internal/web/web.go:612-614 builds tls.Config{Certificates: ...} with no NextProtos, then wraps it with tls.NewListener (web.go:630) and serves via network.ServeHTTP (web.go:649), so it negotiates HTTP/1.1 only. The panel's docs only cover proxying through Nginx/Caddy, with WebSocket Upgrade/Connection headers (docs/content/docs/en/operations/reverse-proxy.mdx:16-20).
Not determined: Which connection returns the 502. The Nginx error.log lines from a failing request, plus whether the 502 page is branded by Cloudflare or by nginx, would settle it.

This reply was generated automatically; a maintainer may follow up.

<!-- gh-comment-id:6409443005 --> @github-actions[bot] commented on GitHub (Oct 26, 2026): The panel isn't part of the HTTP/2 connection in your setup, so I don't think the panel's HTTP/2 support is what causes this 502. Cloudflare's "HTTP/2 to Origin" setting controls the connection from Cloudflare to **Nginx**. Nginx then opens its own separate connection to `127.0.0.1:2053`. To find out which of those two connections fails, I need the logs listed at the end. **Why the panel's protocol doesn't matter here** - `proxy_pass` in Nginx talks to its upstream over HTTP/1.x only (`proxy_http_version` takes `1.0` or `1.1`). This is true whatever Cloudflare uses to reach Nginx. The panel only ever sees HTTP/1.1 from Nginx. - You're right that the panel's own listener doesn't offer HTTP/2. When the panel handles TLS itself, it builds its TLS config without an ALPN list (`internal/web/web.go:612-614`): ```go c := &tls.Config{ Certificates: []tls.Certificate{cert}, } ``` So it only negotiates HTTP/1.1. That only matters when Cloudflare connects straight to the panel port. In your setup Cloudflare connects to Nginx on 443. - So the 502 comes from one of the two connections. Either Cloudflare can't complete HTTP/2 with Nginx, or Nginx gets a bad answer from the panel. In the second case the problem would also show up with "HTTP/2 to Origin" turned off, and you say it doesn't. That points at the Cloudflare ↔ Nginx connection. This is my inference; I can't confirm it without your logs. One more inference: the panel's live updates use WebSockets. Over HTTP/2, a WebSocket needs a special extension (RFC 8441, "extended CONNECT"), and Nginx may not support it. If so, the WebSocket handshake would fail on that same connection. **Please send these, as text:** 1. The 502 page itself: is it a Cloudflare-branded error page (if so, which one: "502 Bad Gateway" or "Error 520/521/525…"?), or a plain `nginx` page? 2. The lines in Nginx's `error.log` (often `/var/log/nginx/error.log`) from the moment you load `domain/3xui/` with HTTP/2 to Origin enabled. 3. Your Nginx version (`nginx -V`) and the full `server { listen 443 ... }` block, with the domain redacted. 4. Whether Nginx runs on the host or in a container. The form says you installed with Docker, but `127.0.0.1:2053` is only reachable from Nginx if both share a network namespace (for example `network_mode: host`). Also, the form says "Is the panel behind a reverse proxy or CDN? → None", but your steps describe Cloudflare in front of Nginx. I've taken the steps as correct. Verdict: Insufficient information Severity: N/A Confidence: Medium Root cause: Not established. The panel only receives HTTP/1.x from Nginx's `proxy_pass`. Its own TLS listener offers no `h2` ALPN (`internal/web/web.go:612-614`), but that hop isn't used in this setup. The failure most likely sits between Cloudflare and Nginx (inference). Same class: None found Already fixed: Not applicable Duplicate of: None Evidence: `internal/web/web.go:612-614` builds `tls.Config{Certificates: ...}` with no `NextProtos`, then wraps it with `tls.NewListener` (`web.go:630`) and serves via `network.ServeHTTP` (`web.go:649`), so it negotiates HTTP/1.1 only. The panel's docs only cover proxying through Nginx/Caddy, with WebSocket `Upgrade`/`Connection` headers (`docs/content/docs/en/operations/reverse-proxy.mdx:16-20`). Not determined: Which connection returns the 502. The Nginx `error.log` lines from a failing request, plus whether the 502 page is branded by Cloudflare or by nginx, would settle it. *This reply was generated automatically; a maintainer may follow up.* <!-- claude-issue:analyst -->
Author
Owner

@HamedSanaei commented on GitHub (Oct 27, 2026):

I checked the current main branch and the project's Nginx reverse-proxy generator. There is not yet enough evidence to conclude this is a 3x-ui HTTP/2 bug.

Findings

  • In internal/web/web.go, the panel's own TLS listener does not explicitly advertise h2 via ALPN. That is relevant to direct TLS connections to the panel, but not necessarily to the deployment described here.
  • The Nginx config generator uses proxy_pass http://127.0.0.1:2053 and proxy_http_version 1.1. In your described topology, enabling Cloudflare's HTTP/2 to Origin affects Cloudflare → Nginx. Nginx makes a separate HTTP/1.1 request to Nginx → 3x-ui, so the panel itself does not need to support HTTP/2 for this setup.
  • WebSocket failures should be distinguished from the initial HTML request failing: a failed WebSocket connection alone does not establish why GET /3xui/ would return 502.
  • Because you use Docker, note that 127.0.0.1 inside an Nginx container refers to that container, not the 3x-ui container. However, that would ordinarily fail regardless of the Cloudflare toggle, so this is only something to verify, not a confirmed cause.

Could you provide the following diagnostics?

  1. Where the 502 is generated: Is the error page Cloudflare-branded or a plain Nginx error? Does the initial document GET /3xui/ fail, or does the page load but only the live-log WebSocket fail? A screenshot or browser DevTools Network entries would help. Please include the timestamp and Cloudflare Ray ID if present.
  2. Nginx logs: Relevant error.log lines (ideally also matching access.log lines) for a failure with HTTP/2 to Origin enabled and a successful request with it disabled.
  3. Nginx topology/config: Output of nginx -V, a redacted version of the relevant server { ... } and location /3xui/ { ... } blocks, the actual proxy_pass target, and whether Nginx runs on the host or in a container (include its network mode).
  4. Bypass Cloudflare and compare the two client protocols to Nginx: Run these from a machine that can reach the origin, replacing the placeholders:
curl -vk --http1.1 --resolve panel.example.com:443:ORIGIN_IP \
  https://panel.example.com/3xui/ -o /dev/null -w 'HTTP/1.1 status: %{http_code}\n'

curl -vk --http2 --resolve panel.example.com:443:ORIGIN_IP \
  https://panel.example.com/3xui/ -o /dev/null -w 'HTTP/2 status: %{http_code}\n'

Please share the HTTP status and negotiated protocol from both outputs. If curl says HTTP/2 is unsupported, send curl -V.
5. Nginx → panel reachability: From the same network namespace as Nginx, test curl -sv http://127.0.0.1:2053/3xui/ -o /dev/null only if your actual proxy_pass uses that HTTP upstream; otherwise test your actual upstream target.

Please redact any domain names, public IPs, credentials, tokens, cookies, and secrets before posting.

Next step: If the direct HTTP/2 request fails while HTTP/1.1 succeeds, we should investigate Nginx's HTTP/2/TLS behavior. If both direct requests succeed but the request through Cloudflare fails, focus on the Cloudflare ↔ Nginx hop. If Nginx logs consistently implicate the upstream panel, we can reproduce a 3x-ui defect and then propose a focused fix.

For now, I would avoid changing the panel's Go HTTP server or opening an HTTP/2 support PR without these results.

<!-- gh-comment-id:6430567350 --> @HamedSanaei commented on GitHub (Oct 27, 2026): I checked the current `main` branch and the project's Nginx reverse-proxy generator. There is not yet enough evidence to conclude this is a 3x-ui HTTP/2 bug. ### Findings - In [`internal/web/web.go`](https://github.com/MHSanaei/3x-ui/blob/main/internal/web/web.go), the panel's own TLS listener does not explicitly advertise `h2` via ALPN. That is relevant to **direct TLS connections to the panel**, but not necessarily to the deployment described here. - The [Nginx config generator](https://github.com/MHSanaei/3x-ui/blob/main/docs/lib/xray/reverse-proxy.ts) uses `proxy_pass http://127.0.0.1:2053` and `proxy_http_version 1.1`. In your described topology, enabling Cloudflare's *HTTP/2 to Origin* affects **Cloudflare → Nginx**. Nginx makes a separate HTTP/1.1 request to **Nginx → 3x-ui**, so the panel itself does not need to support HTTP/2 for this setup. - WebSocket failures should be distinguished from the initial HTML request failing: a failed WebSocket connection alone does not establish why `GET /3xui/` would return 502. - Because you use Docker, note that `127.0.0.1` inside an Nginx container refers to that container, not the 3x-ui container. However, that would ordinarily fail regardless of the Cloudflare toggle, so this is only something to verify, not a confirmed cause. ### Could you provide the following diagnostics? 1. **Where the 502 is generated:** Is the error page Cloudflare-branded or a plain Nginx error? Does the initial document `GET /3xui/` fail, or does the page load but only the live-log WebSocket fail? A screenshot or browser DevTools Network entries would help. Please include the timestamp and Cloudflare Ray ID if present. 2. **Nginx logs:** Relevant `error.log` lines (ideally also matching `access.log` lines) for a failure with *HTTP/2 to Origin* enabled and a successful request with it disabled. 3. **Nginx topology/config:** Output of `nginx -V`, a redacted version of the relevant `server { ... }` and `location /3xui/ { ... }` blocks, the actual `proxy_pass` target, and whether Nginx runs on the host or in a container (include its network mode). 4. **Bypass Cloudflare and compare the two client protocols to Nginx:** Run these from a machine that can reach the origin, replacing the placeholders: ```bash curl -vk --http1.1 --resolve panel.example.com:443:ORIGIN_IP \ https://panel.example.com/3xui/ -o /dev/null -w 'HTTP/1.1 status: %{http_code}\n' curl -vk --http2 --resolve panel.example.com:443:ORIGIN_IP \ https://panel.example.com/3xui/ -o /dev/null -w 'HTTP/2 status: %{http_code}\n' ``` Please share the HTTP status and negotiated protocol from both outputs. If curl says HTTP/2 is unsupported, send `curl -V`. 5. **Nginx → panel reachability:** From the same network namespace as Nginx, test `curl -sv http://127.0.0.1:2053/3xui/ -o /dev/null` **only if** your actual `proxy_pass` uses that HTTP upstream; otherwise test your actual upstream target. Please redact any domain names, public IPs, credentials, tokens, cookies, and secrets before posting. **Next step:** If the direct HTTP/2 request fails while HTTP/1.1 succeeds, we should investigate Nginx's HTTP/2/TLS behavior. If both direct requests succeed but the request through Cloudflare fails, focus on the Cloudflare ↔ Nginx hop. If Nginx logs consistently implicate the upstream panel, we can reproduce a 3x-ui defect and then propose a focused fix. For now, I would avoid changing the panel's Go HTTP server or opening an HTTP/2 support PR without these results.
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#4592
No description provided.