Skip to content

Commit

Permalink
Update h2_tls_web.md (#279)
Browse files Browse the repository at this point in the history
添加Caddy v2 及 H2C配置
  • Loading branch information
MiaoJiawei committed Sep 6, 2023
1 parent 3c8249f commit 286a863
Showing 1 changed file with 113 additions and 0 deletions.
113 changes: 113 additions & 0 deletions zh_CN/advanced/h2_tls_web.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,41 @@ https://<Host> {
```
:::

::: details Caddyfile (Caddy v2)
```caddyfile
https://<Host> {
root * <Path to webroot>
file_server
tls <Path to cert> <Path to key>
proxy <H2 Path> https://localhost:<Port> {
transport http {
tls_insecure_skip_verify
}
header_up Host {host}
header_up X-Real-IP {remote}
header_up X-Forwarded-For {remote}
header_up X-Forwarded-Port {server_port}
header_up X-Forwarded-Proto "https"
}
}
```
:::

::: details Caddyfile (Caddy v2 & H2C)
```caddyfile
https://<Host> {
root * <Path to webroot>
file_server
tls <Path to cert> <Path to key>
proxy <H2 Path> https://localhost:<Port> {
transport http {
versions h2c
}
}
}
```
:::

### V2Ray

下列配置不包含 [log](/basics/log) 部分。
Expand Down Expand Up @@ -127,6 +162,83 @@ https://<Host> {
```
:::

::: details V2Ray Server(H2C) config.json
```json
{
"inbounds": [
{
"port": "<Port>",
"listen": "127.0.0.1",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "<UUID>",
"alterId": 64
}
]
},
"streamSettings": {
"network": "h2",
"security": "none",
# 此处改为"none"
"httpSettings": {
"path": "<H2 Path>",
"host": [
"<Host>"
]
}
}
# "tlsSettings"字段删除
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
```
:::

::: details V2Ray Client(H2C) config.json
```json
"outbounds":
{
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "<Host>",
"port": 443,
"users": [
{
"id": "<UUID>",
"alterId": 64
}
]
}
]
},
"streamSettings": {
"network": "h2",
"security": "tls",
"tlsSettings": {
"serverName": ""
# 注意此处为空值
},
"httpSettings": {
"path": "<H2 Path>",
"host": [
"<Host>"
]
}
}
}
```
:::

## 排错

- 如果你后端的 V2Ray 挂了或配置不正确,访问 *\<H2 Path\>* 仍然会返回 `502`,因此不能通过 `502` 错误判断 V2Ray 正在运行。
Expand All @@ -135,3 +247,4 @@ https://<Host> {
## 参考文献

<b id="f1">1.</b> v2ray-core [#1063](https://github.com/v2ray/v2ray-core/issues/1063)[](#a1)
https://github.com/veekxt/v2ray-template/tree/master/H2C%2Bvmess%2BCaddy2

0 comments on commit 286a863

Please sign in to comment.