English
The xhttp transport
XHTTP (formerly SplitHTTP) from Xray: the protocol stream is split into ordinary HTTP requests; the download goes as one long response, the upload as one streaming request or as a series of POST packets. Passes through CDNs that support neither WebSocket nor gRPC. Compatible with Xray XHTTP over HTTP/1.1, HTTP/2 and HTTP/3; sing-box has no such transport. vless and trojan have XHTTP; HTTP/3 and download are vless only.
Fields
| Field | Type | Default | Meaning |
|---|---|---|---|
mode | string | auto | The mode, see below |
path | string | / | The base path; the session ID and the packet number are appended to it. ?query is allowed |
host | string | tls.sni, otherwise the server address | The host name; a server with host set accepts only that one |
headers | mapping | — | Additional headers; Host, Content-Length, Content-Type, Transfer-Encoding, Connection are not allowed |
http_version | auto, 1.1, 2, 3 | auto | auto is as in Xray: without TLS, HTTP/1.1; with TLS by tls.alpn: exactly h3 gives HTTP/3, exactly http/1.1 gives HTTP/1.1, otherwise (and under REALITY) HTTP/2. 3 is HTTP/3 over QUIC and needs TLS without REALITY |
padding | number | 100 | Padding length in bytes; the server requires no less, up to 8192 |
padding_obfs | block | none | Padding not in Referer but where the block says (Xray xPaddingObfsMode), see below |
uplink | block | see below | How the client sends data |
session, seq | blocks | in the path | Where the session ID and the packet number go, see below |
no_grpc_header | bool | false | The client does not set Content-Type: application/grpc on stream-up/stream-one requests |
no_sse_header | bool | false | The server does not set Content-Type: text/event-stream on streaming responses |
h2 | block | — | The server's HTTP/2 (Xray h2Params): max_concurrent_streams (128), stream_window (2 MiB), connection_window (16 MiB), max_frame_size |
download | block | none | Download from another server (Xray downloadSettings), see below |
posts | block | see below | The POSTs of the packet-up mode: max_bytes — the largest size of one (1000000), max_buffered — how many the server buffers per session (30), min_interval — the smallest interval between the client's POSTs (30ms) |
xmux | block | see below | How the client shares HTTP connections between sessions |
Limits: posts.max_bytes ≤ 16 MiB, posts.max_buffered ≤ 1024, their product ≤ 64 MiB, padding ≤ 8192; going over any of them gives XHTTP buffering/header limits exceeded. Xray names with prefixes (sc_*, x_padding_bytes, c_*, h_*) are an error with a hint.
Modes
mode | Download | Upload |
|---|---|---|
packet-up | GET with a long response | a series of POST /<path>/<session>/<number> |
stream-up | GET with a long response | one streaming POST /<path>/<session> |
stream-one | one POST /<path> request in both directions | |
auto | client: stream-one under REALITY, otherwise packet-up; server: accepts all modes |
In auto the client picks the mode as Xray does; with download under REALITY, stream-up. A server with a specific mode accepts only that one. The upload method is set by uplink.method; the server, like Xray, treats as an upload any request other than GET and a GET with a packet number, and an OPTIONS with Access-Control-Request-Method as a CORS preflight (it answers 200).
Padding, session ID, packet number, data
The fields are Xray names without prefixes; the values are as in Xray.
| Block.field | Xray | Meaning |
|---|---|---|
padding_obfs.placement | xPaddingPlacement | queryInHeader (default: a URL with ?<key>=… in the header header), header, cookie, query |
padding_obfs.key | xPaddingKey | The name of the parameter or cookie (x_padding) |
padding_obfs.header | xPaddingHeader | The header (X-Padding) |
padding_obfs.method | xPaddingMethod | repeat-x (X…) or tokenish (base62, the length by the HPACK Huffman code) |
uplink.method | uplinkHTTPMethod | The upload method (POST); GET only in packet-up |
uplink.data_placement | uplinkDataPlacement | Where the packet data goes: auto/body (the body), header, cookie — base64url in chunks; the last two only in packet-up |
uplink.data_key | uplinkDataKey | The name of the headers <key>-<i> (X-Data) or cookies <key>_<i> (x_data) |
uplink.chunk_size | uplinkChunkSize | The size of a base64 chunk in a header or cookie (from 64; by default 3000–4000 and 2048–3072) |
session.placement, seq.placement | sessionIDPlacement, seqPlacement | path (default), query, header, cookie |
session.key, seq.key | sessionIDKey, seqKey | The name of the parameter, header or cookie (x_session/X-Session, x_seq/X-Seq) |
session.table, session.length | sessionIDTable, sessionIDLength | The ID alphabet (or an Xray name: hex, Base62, …) and length; without them the ID is a UUID |
With data in headers the server must accept such headers: posts.max_bytes should be reduced (Xray's default header limit is 8 KiB). The server answers with CORS headers and padding (X-Padding or per padding_obfs), as Xray does.
download
The session's download goes to another server — the same XHTTP server, but at another address (through a CDN, directly): server: host:port, its own tls (the same block as the outbound's; without it, no TLS) and XHTTP fields for this request (path, host, headers, http_version, padding, xmux, …). The upload goes to the outbound's server. Cannot be combined with stream-one.
HTTP/3
The client opens QUIC connections through the outbound's dialer with its TLS (without uTLS); a server (vless) with XHTTP over HTTP/3 listens on UDP instead of TCP, and TLS is mandatory for it.
xmux
| Field | Meaning |
|---|---|
max_connections | The largest number of HTTP connections; incompatible with max_concurrency (≤ 1024) |
max_concurrency | How many sessions per connection (≤ 65535) |
max_reuse_times | How many times a connection may be reused (0 means no limit) |
max_request_times | How many requests per connection |
max_reusable | How long a connection is fit for new sessions, a duration (e.g. 30m) |
keep_alive_period | The HTTP/2 keep-alive period, a duration (e.g. 30s) |
If xmux is not set at all: max_connections: 3, max_request_times: 600, max_reusable: 30m. If at least one field is set, the others are 0 (no limit).
Example
yaml
inbounds:
vless-xhttp:
vless:
listen: ":443"
users:
- uuid: b831381d-6324-4d53-ad4f-8cda48b30811
tls:
certificate_path: /etc/ours/cert.pem
key_path: /etc/ours/key.pem
transport:
xhttp:
path: /xh
mode: auto
outbounds:
xhttp-out:
vless:
server: cdn.example.com:443
uuid: b831381d-6324-4d53-ad4f-8cda48b30811
tls:
sni: cdn.example.com
transport:
xhttp:
path: /xh
mode: stream-up
xmux:
max_concurrency: 16
max_reusable: 600s
download:
server: 203.0.113.7:443
tls:
sni: cdn.example.com
path: /xh
route:
final:
outbound: xhttp-outWith VLESS Encryption XHTTP also works together with flow: xtls-rprx-vision.