首页 > 服务器 > v2ray使用websocket+tls
作者:ghostry 发布时间:2019-04-14 浏览: 15231
转载注明出处: https://blog.1ge.fun/server/897.htmlv2ray一个更加灵(fu)活(za)的网络工具。
安装v2ray
本文使用docker安装,首先,创建自己的websocket配置文件/data/v2ray/server.json
。按照教程,建议阅读所有再操作。
docker run -d --restart=always -p 172.17.0.1:9000:9000 -v /data/v2ray/server.json:/etc/v2ray/config.json --name=v2ray v2ray/official
一般的,docker使用的是172.17
网段,如果不是,按照实际修改。这句会在172.17.0.1:9000
监听,此端口无法直接使用。运行下面命令查看docker各个容器使用的ip
docker inspect -f '{{.Name}} - {{.NetworkSettings.IPAddress }}' $(docker ps -aq)
配置文件例子,uuid生成cat /proc/sys/kernel/random/uuid
。path可以随便设置,只需保持一致。
{"inbounds":[{"port":9000,"protocol":"vmess","settings":{"clients":[{"id":"xxx-xxx-xxx-xxx-xxx","alterId":64}]},"streamSettings":{"network":"ws","wsSettings":{"path":"/ray"}}}],"outbounds":[{"protocol":"freedom","settings":{}},{"protocol":"blackhole","settings":{},"tag":"block"}],"routing":{"domainStrategy":"AsIs","rules":[{"type":"field","outboundTag":"block","protocol":["bittorrent"]}]}}
安装caddy。
mkdir -p /data/caddy/conf
mkdir -p /data/caddy/html
html文件夹下建议放真正的网页进去,可以随便去网上下载一些html的模板之类的东西放进去。
创建配置文件/data/caddy/conf/Caddyfile
其中的路径ray要和/data/v2ray/server.json
中一致。域名ab.cd.ef
按实际修改
ab.cd.ef {
gzip
root /caddy/html/
index index.html index.htm
proxy /ray 172.17.0.1:9000 {
websocket
header_upstream -Origin
}
}
运行docker
docker run -d --restart=always -p 80:80 -p 443:443 -v /data/caddy:/caddy --name=caddy blob/caddy -conf="/caddy/conf/Caddyfile"
客户端
按照教程编写自己的客户端配置文件/data/v2ray/local.json
,
docker run -d --restart=always -p 1080:1080 -v /data/v2ray/local.json:/etc/v2ray/config.json --name=v2raylocal v2ray/official
配置文件例子,uuid,path,和服务端保持一致。域名按实际修改
上一篇: 资料库搭建{"inbounds":[{"port":1080,"protocol":"socks","sniffing":{"enabled":true,"destOverride":["http","tls"]},"settings":{"auth":"noauth","udp":true}}],"outbounds":[{"protocol":"freedom","settings":{},"tag":"direct"},{"protocol":"vmess","settings":{"vnext":[{"address":"ab.cd.ef","port":443,"users":[{"id":"xxx-xxx-xxx-xxx-xxx","alterId":64}]}]},"tag":"proxy1","streamSettings":{"network":"ws","security":"tls","wsSettings":{"path":"/ray"}}}],"routing":{"domainStrategy":"IPIfNonMatch","balancers":[{"tag":"proxy","selector":["proxy1"]}],"rules":[{"type":"field","outboundTag":"direct","ip":["geoip:private","geoip:cn"]},{"type":"field","outboundTag":"direct","domain":["geosite:cn"]},{"type":"field","network":"tcp,udp","balancerTag":"proxy"}]}}
下一篇: Rocket.Chat服务器搭建