Skip to content

The ws transport (WebSocket) ​

WebSocket per RFC 6455: the client sends a GET with Upgrade: websocket, and after the 101 answer the protocol stream goes in binary frames. Compatible with sing-box and Xray/V2Ray ws; it passes through CDNs and reverse proxies that support WebSocket. Compression (permessage-deflate) is not negotiated.

Fields ​

FieldTypeDefaultMeaning
pathstring/The request path; / is prepended if missing
headersmapping—Additional client headers; Host is taken from here
max_early_datanumber0How many first bytes of the protocol to send right in the request (0-RTT)
early_data_header_namestring—The header for early data; without it, in the path

Client ​

Host is the value of the Host header from headers, and without it the outbound's server address. To go to an IP with a domain Host (typical for a CDN), set headers.Host. Without User-Agent in headers the client sends the User-Agent of the browser whose fingerprint is set in utls, and without utls, Go-http-client/1.1, as sing-box does.

With max_early_data the first bytes of the stream are encoded as base64url without padding and go into the request path or the early_data_header_name header (Xray uses Sec-WebSocket-Protocol); the rest goes in frames after 101.

Server ​

Accepts only GET on its path: with early data in the path, by prefix, otherwise exactly. Host is not checked, and headers are not used on the server (as in sing-box).

Example ​

yaml
inbounds:
  vless-ws:
    vless:
      listen: 127.0.0.1:10000
      users:
        - uuid: b831381d-6324-4d53-ad4f-8cda48b30811
      transport:
        ws:
          path: /ws
          max_early_data: 2048
          early_data_header_name: Sec-WebSocket-Protocol
outbounds:
  cdn:
    vless:
      server: 203.0.113.5:443
      uuid: b831381d-6324-4d53-ad4f-8cda48b30811
      tls:
        sni: cdn.example.com
      transport:
        ws:
          path: /ws
          headers:
            Host: cdn.example.com
          max_early_data: 2048
          early_data_header_name: Sec-WebSocket-Protocol
route:
  final:
    outbound: cdn

The server here listens without TLS behind a reverse proxy that terminates TLS.

GPL-3.0-or-later