docker-compose.yml
这里使用了 nfs 挂载数据卷,也可以直接挂到本地
version: "3.8"
services:
caddy:
image: caddy
ports:
- "80:80"
- "443:443"
- "443:443/udp"
- "22345:22345"
- "22345:22345/udp"
configs:
- source: Caddyfile
target: /etc/caddy/Caddyfile
volumes:
- caddy_data:/data
- caddy_config:/config
v2fly:
image: v2fly/v2fly-core
ports:
- 12345:12345
configs:
- source: v2fly.conf
target: /etc/v2ray/config.json
entrypoint: ["v2ray", "run", "-c", "/etc/v2ray/config.json"]
configs:
Caddyfile:
file: /root/config/caddy/Caddyfile
v2fly.conf:
file: /root/config/v2fly/config.json
volumes:
caddy_data:
driver_opts:
type: "nfs"
o: "addr=nfs-ip,rw"
device: ":/srv/nfs4/caddy_data"
caddy_config:
driver_opts:
type: "nfs"
o: "addr=nfs-ip,rw"
device: ":/srv/nfs4/caddy_config"
Caddyfile
域名:22345 {
root * /usr/share/caddy
file_server
log {
output file /var/log/caddy/access.log
}
tls email@gmail.com
tls {
protocols tls1.2 tls1.3
ciphers TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256
}
@v2ray_ws {
path /long_path
header Connection Upgrade
header Upgrade websocket
}
reverse_proxy @v2ray_ws 域名:12345
}
config.json
由于使用了 Caddy 反代,v2ray 可以不使用 tls
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbound": {
"port": 12345,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "UUID",
"level": 0,
"alterId": 0
}
],
"decryption":"none"
},
"streamSettings": {
"network": "ws",
"security":"none",
"wsSettings": {
"path": "/long_path"
}
}
},
"outbound": {
"protocol": "freedom",
"settings": {}
},
"inboundDetour": [],
"outboundDetour": [
{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}
],
"routing": {
"strategy": "rules",
"settings": {
"rules": [
{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"outboundTag": "blocked"
}
]
}
}
}