v2ray 搭建记录

证书过期了,就顺手升级一下 caddy2.

caddy 升级后直接使用官方 image, 增加了个小脚本自动拉取配置,真香~

感谢秋大 blog 和毕世平 blog

docker 安装以及基本操作可以参考上面两位大神

and 同时默认你搞得定 vps 以及域名等基本操作, 毕竟一搜一大把的教程

搭建

域名解析到 ip

写配置文件

  1. 创建路径 mkdir /etc/v2ray,mkdir /etc/caddy 用以存放配置文件

  2. 写入 v2ray 配置文件,

    vim /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":10000,
    "listen":"127.0.0.1",
    "protocol":"vmess",
    "settings":{
    "clients":[
    {
    "id":"uuid",
    "alterId":64
    }
    ]
    },
    "streamSettings":{
    "network":"ws",
    "wsSettings":{
    "path":"/ray"
    }
    }
    }
    ],
    "outbounds":[
    {
    "protocol":"freedom",
    "settings":{}
    }
    ]
    }
  3. 写入 Caddyfile

    vim /etc/caddy/Caddyfile

    1
    2
    3
    4
    5
    6
    7
    domain.me {
    encode gzip
    reverse_proxy / https://baidu.com
    reverse_proxy /ray 127.0.0.1:10000 {
    header_up -Origin
    }
    }

    修改 domain.me为你自己的域名

    caddy2 和 caddy1 不兼容

run 就完了

docker run -d --name caddy --restart always --net host -v /etc/caddy:/etc/caddy caddy

docker run -d --name v2ray --restart always --net host -v /etc/v2ray:/etc/v2ray teddysun/v2ray

client

客户端相关配置

修改 your.domain.com 域名即可

具体使用方法可参考相关软件文档

clashx

1
{"name":"bwg","type":"vmess","server":"your.domain.com","port":443,"cipher":"auto","udp":false,"uuid":"888d163a-80d7-4495-b3d1-fcf61fc6b6ce","alterId":64,"network":"ws","ws-path":"/ray","ws-headers":{"Host":"bwg.afreto.top"},"tls":true}

v2rayU

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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
{
"log": {
"error": "",
"loglevel": "error",
"access": ""
},
"inbounds": [
{
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": false,
"auth": "noauth"
},
"port": "1086"
},
{
"listen": "127.0.0.1",
"protocol": "http",
"settings": {
"timeout": 360
},
"port": "1087"
}
],
"outbounds": [
{
"mux": {
"enabled": false,
"concurrency": 8
},
"protocol": "vmess",
"streamSettings": {
"wsSettings": {
"path": "/ray",
"headers": {
"host": "bwg.afreto.top"
}
},
"tlsSettings": {
"allowInsecure": true
},
"security": "tls",
"network": "ws"
},
"tag": "proxy",
"settings": {
"vnext": [
{
"address": "bwg.afreto.top",
"users": [
{
"id": "888d163a-80d7-4495-b3d1-fcf61fc6b6ce",
"alterId": 64,
"level": 0,
"security": "auto"
}
],
"port": 443
}
]
}
}
],
"dns": {},
"routing": {
"settings": {
"domainStrategy": "AsIs",
"rules": []
}
},
"transport": {}
}

还是觉得好麻烦啊(一键搞定)

wget https://raw.githubusercontent.com/afret0/v2ray/master/onekey_v2ray.sh && chmod +x onekey_v2ray.sh && ./onekey_v2ray.sh

项目地址

server config

v2ray

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":10000,
"listen":"127.0.0.1",
"protocol":"vmess",
"settings":{
"clients":[
{
"id":"uuid",
"alterId":64
}
]
},
"streamSettings":{
"network":"ws",
"wsSettings":{
"path":"/ray"
}
}
}
],
"outbounds":[
{
"protocol":"freedom",
"settings":{}
}
]
}

Caddyfile

使用 caddy2 版本, 自动安装维护证书是真的香…

1
2
3
4
5
6
7
domain.me {
encode gzip
reverse_proxy / https://baidu.com
reverse_proxy /ray 127.0.0.1:10000 {
header_up -Origin
}
}

附 caddy1 版本(不兼容)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
mydomain.me:80 {
redir https://mydomain.me{url}
}

mydomain.me:443 {
gzip
tls /root/caddy/caddy.crt /root/caddy/caddy.key
log /root/caddy/caddy.log
proxy / https://baidu.com
proxy /ray 127.0.0.1:10000 {
websocket
header_upstream -Origin
}
}

#

// // //