v2ray部署使用

2022/07/04 docker 共 3234 字,约 10 分钟

部署v2ray进行科学上网,并使用google 浏览器插件 SwitchyOmega进行科学上网。

部署v2ray服务端

需要将v2ray服务端部署到国外服务器上

1.配置v2ray服务端配置文件 /etc/v2ray/config.json

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 27652,//这是服务端的端口,客户端配置文件需要
    "protocol": "vmess",//传输协议
    "settings": {
      "clients": [
        {
          "id": "bcaf4ef2-b88a-43f5-b820-a2f45af55ba5",// uuid, 客户端配置文件需要
          "level": 1,
          "alterId": 64
        }
      ]
    }
  },
   "outbounds": [
    {
      "protocol": "freedom",  
      "settings": {}
    }
  ]
}

2.安装

这里使用docker一键安装

docker run \
--name=v2ray \
--net=host \
-v /etc/v2ray/config.json:/etc/v2ray/config.json \
-i -t -d \
v2ray/official:latest

安装客户端

配置文件如下

{
  "inbounds": [
    {
      "port": 30000, 
      "protocol": "socks", 
      "sniffing": {
        "enabled": true,
        "destOverride": ["http", "tls"]
      },
      "settings": {
        "auth": "noauth" 
      }
    },
   {
      "port": 30001,
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess", 
      "settings": {
        "vnext": [
          {
            "address": "2.35.231.61", //服务端ip
            "port": 27652,
            "users": [
              {
                "id": "bcaf4ef2-b88a-43f5-b820-a2f45af55ba5",
                "alterId": 64
              }
            ]
          }
        ]
      }
    }
  ]
}

使用docker部署

docker run -d --name v2ray -v /etc/v2ray/config.json:/etc/v2ray/config.json -p 30001:30001 -p 30000:30000 v2ray/official

科学上网

SwitchyOmega中代理的配置如下:

1.代理协议: Socks5 2.v2ray客户端ip 3.代理端口: 30000

v2ray进阶配置

  1. 基于udp用流量换低延时,另外配置自动路由

  2. 客户端需要下载geoip.dat,geosite.dat
    wget https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat
    wget https://cdn.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat
    
  3. 部署
    docker run -d --restart always --name v2ray -v /etc/v2ray/config.json:/etc/v2ray/config.json -v /opt/docker/v2ray/geoip.dat:/usr/bin/v2ray/geoip.dat -v /opt/docker/v2ray/geosite.dat:/usr/bin/v2ray/geosite.dat -p 30001:30001 v2ray/official
    

客户端配置

{
  "log": {
    "access": "",
    "error": "",
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "port": 30000,
      "protocol": "socks",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      },
      "settings": {
        "auth": "noauth"
      }
    },
    {
      "port": 30001,
      "protocol": "http",
      "sniffing": {
        "enabled": true,
        "destOverride": [
          "http",
          "tls"
        ]
      }
    }
  ],
"outbounds": [
    {
      "tag": "proxy",
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "2.35.231.61",
            "port": 52346,
            "users": [
              {
                "id": "bcaf4ef2-b88a-43f5-b820-a2f45af55ba5",
                "alterId": 64
              }
            ]
          }
        ]
      },
      "streamSettings": {
        "network": "kcp",
        "kcpSettings": {
          "uplinkCapacity": 50,
          "downlinkCapacity": 100,
          "congestion": true,
          "header": {
            "type": "srtp"
          }
        }
      }
    },
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    }
  ],
"routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "mph",
    "rules": [
      {
        "type": "field",
        "outboundTag": "direct",
        "protocol": [
          "bittorrent"
        ]
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "domain": [
          "full:www.icloud.com",
          "domain:icloud-content.com",
          "geosite:google"
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:tld-cn",
          "geosite:icloud",
          "geosite:category-games@cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "domain": [
          "geosite:geolocation-!cn"
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "domain": [
          "geosite:cn",
          "geosite:private"
        ]
      },
      {
        "type": "field",
        "outboundTag": "direct",
        "ip": [
          "geoip:cn",
          "geoip:private"
        ]
      },
      {
        "type": "field",
        "outboundTag": "proxy",
        "network": "tcp,udp"
      }
    ]
  }
}

服务端配置

{
  "inbounds": [
    {
      "port": 52346,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "bcaf4ef2-b88a-43f5-b820-a2f45af55ba5",
            "alterId": 64
          }
        ]
      },
      "streamSettings": {
        "network": "kcp",
        "kcpSettings": {
          "uplinkCapacity": 50,
          "downlinkCapacity": 100,
          "congestion": true,
          "header": {
            "type": "srtp"
          }
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom"
    }
  ]
}

搜索

    内容