首页 > 服务器 > v2ray使用websocket+tls

作者:ghostry 发布时间:2019-04-14 浏览: 2171

转载注明出处: https://blog.ghostry.cn/server/897.html

v2ray一个更加灵(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"}]}}

标签: docker r2ray caddy

上一篇: 资料库搭建
下一篇: Rocket.Chat服务器搭建

添加新评论 »

*
*

欢迎评论!歡迎評論!Comments welcome!komentoj bonvenaj!댓글 오신 것을 환영합니다!
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: :cold: :cryy: :cute: :shy: :sleep: :struggle: :tea: :yahou: