环境

  • alpine 3.16

V2ray

  • 安装
1
2
3
4
5
6
7
8
#安装
apk add v2ray

#开机启动
rc-update add v2ray

#启动
rc-service v2ray
  • 配置/etc/v2ray/config.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
{
"inbounds": [
{
"port": 80,
"listen":"::",
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "#自己生成uuid",
"alterId": 0
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "#自己填写路径"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}

Cloudflare配置

  1. 首页->Workers->Create a Service
  2. 选择Http handlerService Worker Syntax
  3. 右上角Quick edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addEventListener(
'fetch',event => {
let url=new URL(event.request.url);
url.hostname='#自己的域名,如xxx.baidu.com';
if(url.protocol == 'https:') {
url.protocol='http:'
}
let request=new Request(url,event.request);
if(request.headers.has("Origin")) {
request.headers.delete("Origin");
}
event.respondWith(
fetch(request)
)
}
)
  1. 域名管理页面Workers Routes
  2. Route填写域名,如xxx.baidu.com/*
  3. Service选择你创建的Workers Service

参考