陈伦刚
陈伦刚
发布于 2023-06-08 / 90 阅读
0

Docker部署V2ray

提前准备好 config.json 配置文件

{
  "log": {
    "loglevel": "info",
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log"
  },
  "inbounds": [
    {
      "port": 8888,
      "listen":"127.0.0.1",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "7e6b1788-fa3e-4ba5-ae58-d935c8af7c55",
            "alterId": 0
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
        "path": "/happy"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

nginx反代配置

# 定义变量(在头部设置)
map $http_upgrade $connection_upgrade {
  default upgrade;
  ''      close;
}

#v2配置
location /happy {
    proxy_pass       http://127.0.0.1:8888;
    proxy_redirect             off;
    proxy_http_version         1.1;
    proxy_set_header Upgrade   $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host      $http_host;
}

一、镜像

感谢teddysun 制作并提供v2ray的docker镜像


二、部署

docker pull teddysun/v2ray
创建config.json文件
mkdir /etc/v2ray

创建并启动v2ray 容器
vi /etc/v2ray/config.json

启动容器:
docker run -d --network host --name v2ray --restart=always -v /etc/v2ray:/etc/v2ray teddysun/v2ray

建议使用host模式,因为只有host模式支持IPv4/IPv6双协议栈。使用Bridge桥接模式的话,只能支持IPv4.