v2ray 以Linux服务器本地作为代理配置

v2ray 以Linux服务器本地作为代理配置

无咎 32 2023-05-03

v2ray 以Linux服务器本地作为代理配置

下载 v2ray 包

进入 GitHub 地址

https://github.com/v2fly/v2ray-core/releases

找到对应版本进行下载(此处以 4.37.2 版本为例),并解压上传到 Linux 服务器的对应路径

编辑配置文件

先进入到对应路径,然后将默认配置重命名备份

mv config.json config_default.json

完成后新建 config.json 并进行编辑和保存

{
    "inbounds": [
        {
                "port": 10808,
                "listen": "0.0.0.0",
                "protocol": "socks"
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom"
        }
    ]
}

完成后对 v2ray 的权限进行修改

chmod +x v2ray

将 v2ray 制成服务

在 /etc/systemd/system 目录下创建文件 v2ray.service 然后进行编辑和保存

[Unit]
Description = v2ray
After=network.target
Wants=network.target
[Service]
ExecStart=/usr/bin/env v2ray.vmess.aead.forced=false v2ray的绝对路径/v2ray
WorkingDirectory=v2ray的绝对路径
StandardOutput = inherit
StandardError = inherit
Restart = always
LimitNPROC=500
LimitNOFILE=1000000

[Install]
WantedBy = default.target

然后刷新服务,并设置开机自启动

systemctl daemon-reload
systemctl enable v2ray.service

最后启动 v2ray 服务即可

systemctl start v2ray