---
url: /configuration/shared/transport.md
description: ws、httpupgrade、grpc、http 四种 V2Ray stream transport
---

# transport

在 TLS 与代理协议之间再套一层 HTTP 外形。`type` 必须在映射第一项。

```yaml check
outbounds:
  proxy:
    type: socks
    server: proxy.example:443
    transport:
      type: ws
      path: /proxy
      host: cdn.example
      early_data: 2048

dns:
  servers:
    default: {type: udp, address: 127.0.0.1:53}
  final: default
```

## 字段

### type

* 类型：字符串枚举。
* 必填：是，第一项。
* 取值：`ws`、`httpupgrade`、`grpc`、`http`。

### path

* 类型：字符串。
* 默认：实现内建路径。
* 限制：写出的值必须以 `/` 开头；只用于 ws、httpupgrade、http。

### host

* 类型：字符串。
* 必填：可选。
* 行为：HTTP Host。

### headers

* 类型：字符串到字符串的映射。
* 默认：空。
* 限制：只用于 ws、httpupgrade、http。

### early_data

* 类型：非负整数。
* 默认：`0`。
* 限制：只用于 ws。

### early_data_header

* 类型：字符串。
* 必填：可选。
* 限制：只用于 ws，并且要求 `early_data` 大于零。

### service_name

* 类型：字符串。
* 限制：只用于 grpc；不能为空，也不能含 `/` 或空格。

### method

* 类型：HTTP method。
* 限制：只用于 http。

## 说明

| type | 接受的键 |
|---|---|
| `ws` | `path`、`host`、`headers`、`early_data`、`early_data_header` |
| `httpupgrade` | `path`、`host`、`headers` |
| `grpc` | `host`、`service_name` |
| `http` | `path`、`host`、`headers`、`method` |

同样的流可以在入站和出站各套一层，但两端 `type` 和该类型自己的字段必须一致。Shadowsocks 的 SIP003 `plugin` 与 `transport` 都改变 stream 外形，不能同时使用。

## 相关

* [共享块总览](/configuration/shared/)
* [入站总览](/configuration/inbound/#公共嵌套块)
* [出站总览](/configuration/outbound/)
