Skip to content

Instantly share code, notes, and snippets.

@SanariSan
Last active July 8, 2023 11:11
Show Gist options
  • Save SanariSan/cafad9f7fe86eecc6b58ca2957930cd2 to your computer and use it in GitHub Desktop.
Save SanariSan/cafad9f7fe86eecc6b58ca2957930cd2 to your computer and use it in GitHub Desktop.
v2ray hint ubuntu

V2Ray 4.45.2 ( https://github.com/v2fly/v2ray-core/releases/tag/v4.45.2 )

/usr/bin/v2ray = symbolic | v2ray -> /usr/share/v2ray/v2ray*

sudo ln -s /usr/share/v2ray/v2ray /usr/bin/v2ray

touch /etc/systemd/system/v2ray@.service

[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target
StartLimitIntervalSec=0

[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/bin/v2ray run -c /usr/share/v2ray/%i.json
# older versions - ExecStart=/usr/bin/v2ray -config /usr/share/v2ray/%i.json
Restart=always
TimeoutSec=0
RestartSec=30s

[Install]
WantedBy=multi-user.target

config.json

{
  "log": {
    "loglevel": "warning"
  },
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "direct"
      }
    ]
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": "1234",
      "protocol": "socks",
      "settings": {
        "auth": "noauth",
        "udp": false
      }
    },
    {
      "listen": "127.0.0.1",
      "port": "4321",
      "protocol": "http"
    }
  ],
  "outbounds": [
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "site.com",
            "port": 443,
            "users": [{"id":"1a-2b-3c-4d-5e"}],
            "default": {
              "level": 0,
              "security": "chacha20-poly1305"
            }
          }
        ]
      },
      "streamSettings": {
        "network": "ws",
        "security": "tls",
        "tlsSettings": {
          "serverName": "site.com"
        },
        "wsSettings": {
          "path": "/example"
        }
      },
      "tag": "proxy"
    },
    {
      "protocol": "freedom",
      "tag": "direct"
    }
  ]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment