一、docker部署

1. 拉取镜像

docker pull v2fly/v2fly-core

2. 启动容器

docker run -d --name v2ray --restart=always -v /root/v2ray/config.json:/etc/v2fly/config.json -p 10240:10240 v2fly/v2fly-core run -c /etc/v2fly/config.json

二、直接部署

1. 安装主程序和 .dat 数据文件

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

安装完成后配置文件位置:/usr/local/etc/v2ray/config.json

自行编辑

2. 更新 .dat 数据文件

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh)

3. 添加自启动以及运行 V2Ray 服务器

systemctl enable v2ray
systemctl start v2ray

4. 卸载 V2Ray 的方法

bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove

三、服务端配置范例

{
    "inbounds": [
        {
            "port": 10240,
            "protocol": "vmess",
            "settings": {
                "clients": [
                    {
                        "email": "user1@xxx.com",
                        "id": "ff75ea18-42f0-41f1-98c0-0033ca5697ff",
                        "level": 0,
                        "alterId": 0
                    },
                    {
                        "email": "user2@xxx.com",
                        "id": "bf267627-27a7-4fd1-a628-4de1746024ce",
                        "level": 0,
                        "alterId": 0
                    },
                    {
                        "email": "user3@xxx.com",
                        "id": "ecc5ed4e-77a9-44bc-b8f7-2e2ec51faf18",
                        "level": 0,
                        "alterId": 0
                    }
                ]
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

四、客户端.yaml配置文件范例(基于openclash测试)

# OpenClash Config
mixed-port: 7890
redir-port: 7892
socks-port: 7891
mode: rule
log-level: info
external-controller: 127.0.0.1:9090
external-ui: "/usr/share/openclash/dashboard"
dns:
  enable: true
  ipv6: false
  listen: 0.0.0.0:53
  enhanced-mode: redir-host
  nameserver:
    - 114.114.114.114
    - 8.8.8.8

proxies:
  - name: 香港
    type: vmess
    server: 123.123.123.123 #代理IP
    port: 10240
    uuid: 38fe8e5c-a198-4b2b-8cf8-439919d29e33 #用户id
    alterId: 0
    cipher: auto
    udp: true
    tls: false
  - name: 洛杉矶(美国)
    type: vmess
    server: 124.124.124.124 #代理IP
    port: 10240
    uuid: 38fe8e5c-a198-4b2b-8cf8-439919d29e33 #用户id
    alterId: 0
    cipher: auto
    udp: true
    tls: false

proxy-groups:
  - name: ?直接连接
    type: select
    proxies:
      - DIRECT
  - name: ?节点选择
    type: select
    proxies:
      - 香港
      - 洛杉矶(美国)
      - ?直接连接
  - name: ♻️自动选择
    type: url-test
    url: 'http://www.msftconnecttest.com/connecttest.txt'
    interval: 300
    proxies:
      - 香港
      - 洛杉矶(美国)
  - name: ?国内网络
    type: select
    proxies:
      - ?直接连接
      - ?节点选择
      - ♻️自动选择
  - name: ?国外网络
    type: select
    proxies:
      - ?节点选择
      - ♻️自动选择
      - ?直接连接
  - name: ?漏网之鱼
    type: select
    proxies:
      - ?节点选择
      - ♻️自动选择
      - ?直接连接

rule-providers:
  LAN:
    type: file
    behavior: "classical"
    path: LAN
    interval: 86400
  ChatGPT:
    type: file
    behavior: "classical"
    path: ChatGPT
    interval: 86400

rules:
  - RULE-SET,LAN,DIRECT
  - IP-CIDR,代理服务器IP1/32,DIRECT,no-resolve #排除代理服务器本身(防止自己访问服务器的时候还要绕一次别的代理)
  - IP_CIDR,代理服务器IP2/32,DIRECT,no-resolve #排除代理服务器本身(防止自己访问服务器的时候还要绕一次别的代理)
  - RULE-SET,ChatGPT,洛杉矶(美国)
  - GEOIP,CN,?国内网络
  - MATCH,?国外网络
最后更新于 2023-07-15