2023-03-12

docker 配置 v2Ray(PC端)

作者 万有引力

前提条件

https://www.jianshu.com/p/00818620b54b

你需要有或者租了一台如香港台湾等地的服务器


一、服务端配置

首先下载v2ray镜像

[root@RrLdEU38437 ~]# docker search v2ray
NAME                           DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
v2ray/official                 V2Ray official docker image.                    447                  [OK]
teddysun/v2ray                 V2Ray Docker Image by Teddysun                  291
mzz2017/v2raya                 A web GUI client of Project V which supports…   73
mritd/v2ray                    v2ray docker image                              37                   [OK]
v2ray/dev                      V2Ray developer builds                          34                   [OK]
bclswl0827/v2ray-openshift     V2Ray for Openshift.                            27                   [OK]
hulisang/v2ray_v3              v2ray后端,用于对接sspanel                             23
wangyi2005/v2ray               v2ray                                           22                   [OK]
mzz2017/v2raya-gui             demo: https://v2raya.mzz.pub                    18
pengchujin/v2ray_ws                                                            15
zydou/v2ray                    V2Ray 路由规则文件加强版,代替 V2Ray 官方 ge…                 10
gists/v2ray                    [unofficial] based on alpine and building fr…   10                   [OK]
lihaixin/v2ray                 v2ray in docker                                 7                    [OK]
letssudormrf/v2ray-docker      v2ray-docker                                    7                    [OK]
gingko/v2ray-nginx-websocket   github.com/clicocc/v2ray-docker                 4
offthewall/v2ray               v2ray                                           1                    [OK]
superng6/v2ray                 v2ray latest                                    1
orvice/v2ray-mu                v2ray-mu                                        1                    [OK]
vmopens/v2ray                  my v2ray                                        0                    [OK]
wi1dcard/v2ray-exporter        Prometheus exporter for V2Ray metrics, with …   0
doresimon/v2ray-server                                                         0
v2raysrgo/crack-soga                                                           0
vulcan321/v2ray                                                                0
v2raysrgo/ssrgo                ssrgo                                           0
arthursun51/v2ray              v2ray                                           0                    [OK]

下载v2ray/official

[root@RrLdEU38437 ~]# docker pull v2ray/official
Using default tag: latest
latest: Pulling from v2ray/official
c9b1b535fdd9: Pull complete
e988f487316f: Pull complete
9f14b9e76a1c: Pull complete
ba8aa6f3f262: Pull complete
47a7d45748ed: Pull complete
a1eaab65098b: Pull complete
95f134d2f540: Pull complete
Digest: sha256:978c67f3dba2afb01b710620f8bc0392b36729facad466b90a49f3d7f30404be
Status: Downloaded newer image for v2ray/official:latest
docker.io/v2ray/official:latest

配置v2ray

配置信息如下

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [{
    "port": 8001,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "54bce14a-95e1-4444-8a2e-1f7bb78009f4",
          "level": 1,
          "alterId": 64
        }
      ]
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  }]
}

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbounds": [{
    "port": 8001,
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "54bce14a-95e1-4444-8a2e-1f7bb78009f4",
          "level": 1,
          "alterId": 64
        }
      ]
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  }]
}
启动v2ray

[root@RrLdEU38437 ~]# docker run -dp 8001:8001 --name v2ray -v /soft/v2ray:/etc/v2ray -v /soft/log:/var/log/v2ray v2ray/official
97ef33e509385a5c6193d10d754232efcdc74dba0c9cc2724c5bf731744d669b
查看启动情况

[root@RrLdEU38437 ~]# docker ps
CONTAINER ID   IMAGE                     COMMAND                  CREATED              STATUS              PORTS                                          NAMES
97ef33e50938   v2ray/official            "v2ray -config=/etc/…"   About a minute ago   Up About a minute   0.0.0.0:8001->8001/tcp                         v2ray

至此v2ray已经启动完毕

配置客户端

下载v2ray客户端
  1. 下载地址:https://github.com/2dust/v2rayN/releases
    如遇到下载不了情况,备用地址:
    链接:https://pan.baidu.com/s/1W9XpbtGYe6EjP57Ba-s6MQ
    提取码:clxa
  2. 下面配置v2ray
  • 打开客户端,选择服务器,选择添加[Vmess]服务器。
  • 别名(remarks) 随便填
  • 地址(address) 选择服务器所在IP地址信息
  • 端口(port) 与服务器conig.json中的端口一致

  • 配置用户ID(id)
  • 该id就是UUID生成的ID,一定要一致,否则会报错
  • 额外ID(alterId),额外ID要与config.json中的alterId一致
  • 其他配置选项默认即可

点击确定即可

  • 系统代理选择自动配置系统代理
  • 路由选择绕过大陆

配置完成

查看v2ray日志信息

[root@RrLdEU38437 log]# tail -f access.log
2023/01/23 06:41:49 117.89.34.188:23950 accepted tcp:www.google.com:443
2023/01/23 06:42:19 117.89.34.188:23972 accepted tcp:www.bing.com:443
2023/01/23 06:42:19 117.89.34.188:23973 accepted tcp:www.bing.com:443
2023/01/23 06:42:25 117.89.34.188:23976 accepted tcp:www.youtube.com:443
2023/01/23 06:42:25 117.89.34.188:23977 accepted tcp:i.ytimg.com:443
2023/01/23 06:42:25 117.89.34.188:23978 accepted tcp:data-api.similarsites.com:443
2023/01/23 06:42:25 117.89.34.188:23979 accepted tcp:rr3---sn-q4fl6nsk.googlevideo.com:443
2023/01/23 06:42:25 117.89.34.188:23980 accepted tcp:rr3---sn-q4fl6nsk.googlevideo.com:443
2023/01/23 06:42:25 117.89.34.188:23981 accepted tcp:clients4.google.com:443
2023/01/23 06:42:26 117.89.34.188:23983 accepted tcp:i.ytimg.com:443
2023/01/23 06:42:26 117.89.34.188:23985 accepted tcp:rr3---sn-q4fl6n6d.googlevideo.com:443
2023/01/23 06:42:26 117.89.34.188:23984 accepted tcp:rr3---sn-q4fl6n6d.googlevideo.com:443
2023/01/23 06:42:27 117.89.34.188:23986 accepted tcp:yt3.ggpht.com:443
2023/01/23 06:42:28 117.89.34.188:23988 accepted tcp:www.google.com:443
2023/01/23 06:42:28 117.89.34.188:23989 accepted tcp:jnn-pa.googleapis.com:443

配置信息

登录如youtube.com等地址验证是否ok

作者:书俊俊软件开发工作室
链接:https://www.jianshu.com/p/00818620b54b
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。