V2ray Server

V2ray Server #

Installation #

The V2ray server need to deploy into a server can access to restricted network.

cd /tmp/
wget https://github.com/v2fly/v2ray-core/releases/download/v4.27.5/v2ray-linux-64.zip
unzip v2ray-linux-64.zip 

sudo mv v2ctl v2ray /usr/local/bin/
sudo chown -R nobody:nogroup /usr/local/bin/v2ray
sudo chown -R nobody:nogroup /usr/local/bin/v2ctl

sudo mkdir -p /usr/local/etc/v2ray/
sudo touch /usr/local/etc/v2ray/config.json
sudo chown -R nobody:nogroup /usr/local/etc/v2ray

sudo mkdir -p /var/log/v2ray
sudo chown -R nobody:nogroup /var/log/v2ray

sudo mv systemd/system/v2ray* /lib/systemd/system/

Configuation #

  • /usr/local/etc/v2ray/config.json
{
  "log": {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "dns": {},
  "stats": {},
  "inbounds": [
    {
      "listen": "0.0.0.0",
      "port": 443,
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "4049dc7a-3aca-4882-aa75-fa9b9a86091f",
            "alterId": 64
          }
        ]
      },
      "tag": "in-0",
      "streamSettings": {
        "network": "h2",
        "security": "tls",
        "tlsSettings": {
          "serverName": "abc.example.com",
          "certificates": [
            {
              "certificateFile": "/etc/ssl/v2ray/v2ray.crt",
              "keyFile": "/etc/ssl/v2ray/v2ray.key"
            }
          ],
          "allowInsecure": true
        },
        "httpSettings": {
          "path": "/ray"
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ],
  "policy": {},
  "reverse": {},
  "transport": {}
}

There are only some params you need to adjust:

id: User ID, in the form of a UUID. Online UUID Generator: https://www.uuidgenerator.net

alterId: Number of alternative IDs.

serverName: Your subdomain for access.

certificateFile: Filepath of your SSL cert file for subdomain .

keyFile: Filepath of your SSL key file for subdomain.

path: HTTP path for access.

Startup #

Once you finished the configuration, you can start up the v2ray server.

systemctl start v2ray
systemctl enable v2ray