唯's Blog

笔者是一个热爱编程的 Java 程序员。

0%

搭建代理服务

使用 v2ray 来实现代理访问,v2ray 功能很强大我这里只使用 VMess 传输代理

https://guide.v2fly.org/basics/vmess.html

以上部署方式为 Docker

服务端部署

  1. 拉取镜像:sudo docker pull v2fly/v2fly-core

  2. 提前准备日志文件 access.log、error.log 。例如:touch /opt/v2test/logs/access.log

  3. 创建配置文件,配置文件目录自定义(要跟 docker run 目录挂载目录保持一致):vim /opt/v2test/config.json

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

> {

> "log": {

> "loglevel": "debug",

> "access": "/etc/v2ray/logs/access.log",

> "error": "/etc/v2ray/logs/error.log"

> },

> "inbounds":[

> {

> "port": 8080,

> "protocol": "vmess",

> "settings":{

> "clients":[

> {

> "id": "023017b3-101d-453e-b92d-fc67b21969d5",

> "alterId": 0

> }

> ]

> }

>

> }

> ],

> "outbounds": [

> {

> "protocol": "freedom",

> "settings": {}

> }

> ]

>

> }

“id” 的生成策略是uuid,可以使用linux自带程序生成:cat /proc/sys/kernel/random/uuid

这里的id相当于访问密码,客户端连接配置要输入该值

  1. 启动 v2fly 容器: docker run –env v2ray.vmess.aead.forced=false -d –name v2ray -e TZ=Asia/Shanghai -v /opt/v2test:/etc/v2ray -p 8080:8080 –restart always v2fly/v2fly-core run -c /etc/v2ray/config.json

这里用三个关键点:

  1. –env v2ray.vmess.aead.forced=false 关闭该策略,”alterId”: 0 这里很关键,被坑惨了
  1. -p 8080:8080 暴露的端口号 要和配置文件中一致
  1. -v /opt/v2test:/etc/v2ray 挂载配置文件
  1. 按照上述步骤,正常情况是没问题的。如果有异常,进入配置文件中配置的log路径,查看日志。例如:tail -f /opt/v2test/error.log

客户端配置

客户端配置,这里介绍 ios 系统操作方式(其他系统参考:https://www.v2ray.com/awesome/tools.html)

  1. 苹果手机安装软件 oneClick

  2. 添加配置,选择 VMESS,IP 端口 ID alertId 要和上述配置文件保持一致,流设定 tcp 默认。