Xray-docs-next/docs/en/config/transports/h2.md

83 lines
2.6 KiB
Markdown

# HTTP/2
The transmission mode based on HTTP/2 fully implements the HTTP/2 standard and can be relayed by other HTTP servers (such as Nginx).
Based on the recommendations of HTTP/2, both the client and server must enable TLS to use this transmission mode normally.
HTTP/2 has built-in multiplexing, so it is not recommended to enable mux.cool when using HTTP/2.
::: tip
The current version of the transmission mode based on HTTP/2 does not require TLS configuration for inbound (server-side).
This makes it possible to use a plaintext HTTP/2 protocol called h2c for communication between the gateway and Xray, with external gateway components handling the TLS layer conversation in special-purpose load-balancing deployment environments.
:::
::: warning
⚠️ If you are using fallback, please note the following:
- Please make sure that `h2` is included in `(x)tlsSettings.alpn`, otherwise HTTP/2 cannot complete TLS handshake.
- HTTP/2 cannot perform path-based routing, so it is recommended to use SNI-based routing.
:::
## HttpObject
`HttpObject` corresponds to the `httpSettings` in the [Transport Protocol](../transport.md),
```json
{
"host": ["xray.com"],
"path": "/random/path",
"read_idle_timeout": 10,
"health_check_timeout": 15,
"method": "PUT",
"headers": {
"Header": ["value"]
}
}
```
> `host`: \[string\]
A string array, where each element is a domain name.
The client will randomly select a domain name from the list for communication, and the server will verify whether the domain name is in the list.
> `path`: string
The HTTP path starts with `/` and must be the same value between the client and server.
The default value is `/`
> `read_idle_timeout`: number
The connection health check is performed when no data has been received for a certain period of time, measured in seconds.
By default, the health check is **disabled**.
::: tip
**Only need to be configured** in **`outbound`** (**client**).
:::
::: tip
Enabling health checks may help solve some "connection drop" issues.
:::
> `health_check_timeout`: number
The timeout for the health check, measured in seconds. If the health check is not completed within this time period, it is considered to have failed.
The default value is `15`
::: tip
**Only need to be configured** in `outbound` **(client)**.
:::
> `method`: string
HTTP request method. The default value is `PUT`
Please refer this [this](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods) when configure.
> `headers`: map{ string: \[string\] }
Custom HTTP headers, defined as key-value pairs. Each key represents an HTTP header name and its corresponding value is an array.