62 lines
2.1 KiB
Markdown
Raw Normal View History

2021-05-26 19:05:53 +08:00
# WebSocket
Use standard WebSocket to transmit data.
2021-05-26 19:05:53 +08:00
WebSocket connections can be peoxied by other HTTP servers (such as Nginx) or by VLESS fallbacks path.
2021-05-26 19:05:53 +08:00
::: tip
Websocket will recognize the X-Forwarded-For header of the HTTP request to override the source address of the traffic, with a higher priority than the PROXY protocol.
2021-05-26 19:05:53 +08:00
:::
## WebSocketObject
`WebSocketObject` corresponds to the `wsSettings` item of the transport configuration.
2021-05-26 19:05:53 +08:00
```json
{
"acceptProxyProtocol": false,
"path": "/",
"headers": {
"Host": "xray.com"
}
}
```
> `acceptProxyProtocol`: true | false
Only used for inbound, indicating whether to accept the PROXY protocol.
2021-05-26 19:05:53 +08:00
The [PROXY protocol](https://www.haproxy.org/download/2.2/doc/proxy-protocol.txt) is used to transmit the real source IP and port of the request. **If you are not familiar with it, please ignore this item.**
2021-05-26 19:05:53 +08:00
Common reverse proxy software (such as HAProxy and Nginx) can be configured to send it, and VLESS fallbacks xver can also send it.
2021-05-26 19:05:53 +08:00
When filled in as `true`, after the underlying TCP connection is established, the requesting party must first send PROXY protocol v1 or v2, otherwise the connection will be closed.
2021-05-26 19:05:53 +08:00
> `path`: string
2021-05-26 19:05:53 +08:00
The HTTP protocol path used by WebSocket. Default is `"/"`
2021-05-26 19:05:53 +08:00
If the path contains the `ed` parameter, `Early Data` will be enabled to reduce latency, and its value is the first packet length threshold. If the length of the first packet exceeds this value, `Early Data` will not be enabled. The recommended value is 2048.
An example usage of `ed` parameter:
```
"path": "/aabbcc" //original path
"path": "/aabbcc?ed=2048" //added ed parameter
```
2021-05-26 19:05:53 +08:00
::: warning
`Early Data` uses the `Sec-WebSocket-Protocol` header to carry data. If you encounter compatibility issues, try lowering the threshold.
2021-05-26 19:05:53 +08:00
:::
> `headers`: map \{string: string\}
Custom HTTP headers, a key-value pair, where each key represents the name of an HTTP header, and the corresponding value is a string.
2021-05-26 19:05:53 +08:00
The default value is empty.
2021-05-26 19:05:53 +08:00
## Browser Dialer
2021-05-26 19:05:53 +08:00
Use the browser to handle TLS, see [Browser Dialer](../features/browser_dialer.md)