服务器端不需要配置TLS,只需要把HTTPS解密工作交给caddy,也就是配置caddy使用SSL证书,服务器端v2ray只需要接受明文WebSocket连接即可.
~~~json
{
"log" : {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbound": {
"port": 1110,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "你的uid",
"level": 1,
"alterId": 64,
"email": "
[email protected]"
}
]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"connectionReuse": false,
"path": "/ws"
}
}
},
"outbound": {
"protocol": "freedom",
"settings": {}
},
"inboundDetour": [
{
"protocol": "shadowsocks",
"port": 1112,
"settings": {
"method": "chacha20",
"password": "1234567",
"udp": false
}
},
{
"protocol": "shadowsocks",
"port": 1113,
"settings": {
"method": "chacha20",
"password": "1234567",
"udp": false
}
}
],
"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"
}
]
}
}
}
~~~
------------------
#### [v2ray客户端文件](#2)
~~~json
{
"inbound": {
"port": 1080,
"listen": "0.0.0.0",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": true,
"ip": "127.0.0.1",
"clients": null
},
"streamSettings": null
},
"outbound": {
"tag": "wsout",
"protocol": "vmess",
"settings": {
"vnext": [
{
"address": "你的网站域名",
"port": 443,
"users": [
{
"id": "你的uid",
"alterId": 64,
"security": "aes-128-gcm"
}
]
}
]
},
"streamSettings": {
"network": "ws",
"security": "tls",
"tlsSettings": {
"serverName": "你的网站域名",
"allowInsecure": true
},
"wsSettings": {
"connectionReuse": true,
"path": "/ws"
}
},
"mux": {
"enabled": true
}
},
"outboundDetour": [
{
"protocol": "freedom",
"settings": {
"response": null
},
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": {
"response": {
"type": "http"
}
},
"tag": "blockout"
}
],
"dns": {
"servers": [
"8.8.8.8",
"8.8.4.4",
"localhost"
]
},
"routing": {
"strategy": "rules",
"settings": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"port": null,
"outboundTag": "direct",
"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"
],
"domain": null
}
]
}
}
}
~~~
------------------------
#### [caddy配置文件:/usr/local/caddy/Caddyfile](#3)
假设你的域名是xxxx.com,证书.crt和.key放在:/etc/v2ray/
~~~php
http://xxxx.com {
redir https://xxxx.com {url}
}
https://xxxx.com {
root /var/www/index
gzip
index index.html
tls /etc/v2ray/v2ray.crt /etc/v2ray/v2ray.key
proxy /ws localhost:1110 {
websocket
}
}
~~~