Xray-core: XHTTP H3 fails for "alpn: h3", only supports "alpn: h3-29"
Integrity requirements
- I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
- I provided the complete config and logs, rather than just providing the truncated parts based on my own judgment.
- I searched issues and did not find any similar issues.
- The problem can be successfully reproduced in the latest Release
Description
basic flow: Xray client (XHTTP+TLS+H3) [!FAIL!] -> [!FAIL!] Nginx (TLS decode + H3) -> Xray Server (XHTTP)
I tested with Haproxy (3.1) and Nginx (1.28.0), build with openssl 3.5.0 or quictls 3.3.0. I tested with curl (HTTP3), openssl (3.2.0), and browser, to make sure haproxy/nginx is able to serve http3 content (accept HTTP REQ and send RSP via H3). It looks like the connection failed at TLS handshake when xray client try to connect nginx h3 server.
log from nginx attached below. asking chatgpt, it says there needs to be:
&tls.Config{
NextProtos: []string{"h3"},
}
And it looks like https://github.com/XTLS/Xray-core/blob/922ae98a4ad133fe8d421fc2da551f92baed9ed9/transport/internet/splithttp/dialer.go#L163 does not have it (I could be wrong) chatgpt also suggest that current xray code might be compatible with http3 draft 29, but not with http3 offcial rfc9114.
For haproxy, even H2 does not get through (haproxy frontend mode http), because haproxy has more strict checks for HTTP Request, and recognize xray’s xhttp connection as “BAD REQ”. If xray’s XHTTP can be proxied by Haproxy, it can take advantage of the haproxy’s QUIC BBR congestion control. Whereas nginx currently support CUBIC for QUIC. (Both better than default new Reno of quic-go) Edit: I just did a test, and xray client making H3 connection to CF also doesn’t work. flow: xray xhttp client (H3) -> (H3) CF (H2) -> (H2) nginx -> xray server xray xhttp client (H3) [!FAIL!] <- [!FAIL!] (H3) CF (H2) <- (H2) nginx <- xray server
Edit: As I tested more, as described in https://github.com/XTLS/Xray-core/issues/4652#issuecomment-2838187582 , I confirmed that xray http3 only support “alpn: h3-29”. As a result, when the server only supports “alpn: h3”, xray http3 fails at tls handshake. Test is simple & straight forward: curl https://www.mysite.com/ -I --http3-only --alpn h3 curl https://www.mysite.com/ -I --http3-only --alpn h3-29 these tests show that cloudflare supports “alpn: [h3, h3-29]”, while [nginx 1.28.0 + quictls3.3.0/aws-lc 1.50.0] only supports “alpn: [h3]”. Since the nginx error log of [xray http3] is basically same as nginx error log of [curl --alpn h3-29], we can conclude that xray behaves the same as h3-29, and cannot switch to h3 if h3-29 fails.
Reproduction Method
Xray client (XHTTP+TLS+H3) -> Nginx (TLS decode + H3) -> Xray Server (XHTTP)
Client config
"security": "tls",
"tlsSettings": {
"fingerprint": "edge",
"serverName": "h3.host.com",
"alpn": ["h3"],
"minVersion": "1.3",
"maxVersion": "1.3"
},
"network": "xhttp",
"xhttpSettings": {
"mode": "auto",
"host": "h3.host.com",
"path": "/xray-xhttp/",
"noGRPCHeader": true,
Server config
nginx config:
server {
listen [::]:443 quic ipv6only=off;
location /xray-xhttp {
proxy_pass http://unix:/dev/shm/xrayInXHttp.socket;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_http_version 1.1;
proxy_request_buffering off;
proxy_redirect off;
proxy_read_timeout 5m;
proxy_send_timeout 5m;
proxy_socket_keepalive on;
}
ssl_certificate /etc/ssl/domains/default/cert.pem;
ssl_certificate_key /etc/ssl/domains/default/privkey.pem;
}
Client log
2025/04/26 18:20:28.275854 [Info] [3134730367] transport/internet/splithttp: XHTTP is dialing to udp:1.2.3.4:443, mode packet-up, HTTP version 3, host h3.test.com
2025/04/26 18:20:28.276403 [Info] [3134730367] transport/internet/splithttp: XHTTP is downloading from udp:1.2.3.4:443, mode stream-down, HTTP version 3, host h3.test.com
2025/04/26 18:20:28.418479 [Info] [2679253649] proxy/socks: TCP Connect request to tcp:edge.microsoft.com:443
transport/internet/splithttp: failed to GET https://h3.test.com/xray-xhttp/x000xxx-xxxx-xxxx-xxxx-xxxx00sxx > Get "https://h3.test.com/xray-xhttp/x000xxx-xxxx-xxxx-xxxx-xxxx00sxx": timeout: no recent network activity
Server log
Nginx server log:
2025/04/26 10:20:41 [debug] 50345#50345: epoll timer: 5605
2025/04/26 10:20:45 [debug] 50346#50346: timer delta: 3992
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer del: 14: 428590597
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic pto timer
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic pto init pto_count:2
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic sendto init packet max:1200 min:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic frame tx init:8 PING
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic packet tx init bytes:3 need_ack:0 number:8 encoded nl:1 trunc:0x8
2025/04/26 10:20:45 [debug] 50346#50346: *18 sendmsg: 49 of 49
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic congestion send if:4037
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic lost timer pto:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer add: 14: 0:428590601
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic sendto init packet max:1200 min:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic frame tx init:9 PING
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic packet tx init bytes:3 need_ack:0 number:9 encoded nl:1 trunc:0x9
2025/04/26 10:20:45 [debug] 50346#50346: *18 sendmsg: 49 of 49
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic congestion send if:4086
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer del: 14: 428590601
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic lost timer pto:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer add: 14: 0:428590601
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic pto hs pto_count:2
2025/04/26 10:20:45 [debug] 50346#50346: *18 posix_memalign: 0000000001DA1D30:512 @16
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic sendto hs packet max:1200 min:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic frame tx hs:14 PING
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic packet tx hs bytes:3 need_ack:0 number:14 encoded nl:1 trunc:0xe
2025/04/26 10:20:45 [debug] 50346#50346: *18 sendmsg: 48 of 48
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic congestion send if:4134
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer del: 14: 428590601
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic lost timer pto:3988
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer add: 14: 3988:428594589
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic sendto hs packet max:1200 min:0
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic frame tx hs:15 PING
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic packet tx hs bytes:3 need_ack:0 number:15 encoded nl:1 trunc:0xf
2025/04/26 10:20:45 [debug] 50346#50346: *18 sendmsg: 48 of 48
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic congestion send if:4182
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer del: 14: 428594589
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic lost timer pto:3988
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer add: 14: 3988:428594589
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer del: 14: 428594589
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic lost timer pto:7976
2025/04/26 10:20:45 [debug] 50346#50346: *18 event timer add: 14: 7976:428598577
2025/04/26 10:20:45 [debug] 50346#50346: *18 quic state: send:57817 pto:7976 close:52817
2025/04/26 10:20:45 [debug] 50346#50346: worker cycle
2025/04/26 10:20:45 [debug] 50346#50346: epoll timer: 1954
2025/04/26 10:20:47 [debug] 50346#50346: timer delta: 1957
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 17 (10 by maintainers)
模板不完整 XHTTP3 nginx 有人在用 不太可能有问题