准备工作

宝塔安装

https://www.bt.cn/

根据系统自己来吧,建议使用centos。

网站搭建

建议安装LNMP (第一个,NGINX替代了LAMP的Apache。)

NGINX的代理功能是关键。php注意是7.0及以上的版本,mysql建议保持默认的5.7别动。

安装v2ray

在以下的网站中安装v2ray服务端。

https://github.com/v2fly/fhs-install-v2ray#fhs-install-v2ray

fhs-install-v2ray

欲查阅以简体中文撰写的介绍,请访问:README.zh-Hans-CN.md

Bash script for installing V2Ray in operating systems such as Debian / CentOS / Fedora / openSUSE that support systemd

該腳本安裝的文件符合 Filesystem Hierarchy Standard(FHS):

https://wiki.linuxfoundation.org/lsb/fhs

installed: /usr/local/bin/v2ray
installed: /usr/local/bin/v2ctl
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/[email protected]

依賴軟體

安裝 cURL

# apt update
# apt install curl

or

# yum makecache
# yum install curl

or

# dnf makecache
# dnf install curl

or

# zypper refresh
# zypper install curl

下載

// 安装本体和数据文件
# curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh
// 只更新数据文件
# curl -O https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-dat-release.sh

使用

  • 該腳本在執行時會提供 infoerror 等信息,請仔細閱讀。

安裝和更新 V2Ray

# bash install-release.sh

安裝最新發行的 geoip.dat 和 geosite.dat

# bash install-dat-release.sh

移除 V2Ray

# bash install-release.sh --remove

解決問題

參數

usage: install-release.sh [--remove | --version number | -c | -f | -h | -l | -p]
  [-p address] [--version number | -c | -f]
  --remove        Remove V2Ray
  --version       Install the specified version of V2Ray, e.g., --version v4.18.0
  -c, --check     Check if V2Ray can be updated
  -f, --force     Force installation of the latest version of V2Ray
  -h, --help      Show help
  -l, --local     Install V2Ray from a local file
  -p, --proxy     Download through a proxy server, e.g., -p http://127.0.0.1:8118 or -p socks5://127.0.0.1:1080

維護

請於 develop 分支進行,以避免對主分支造成破壞。

待確定無誤後,兩分支將進行合併。

安装完v2ray之后修改配置文件

v2ray的配置文件一般在如下位置

/usr/local/etc/v2ray/config.json

config.json样例:

{
  "inbounds": [{
    "port": 65432,           //此处为安装时生成的端口,可修改随意,但是保证和下面提到的端口号相同
    "listen":"127.0.0.1",
    "protocol": "vmess",
    "settings": {
      "clients": [
        {
          "id": "c55ad-9c79-4907-905d-259", //此处为安装时生成的id,也可以在网页上自行获取,但是不要自己瞎写
          "level": 1,
          "alterId": 64      //此处为安装时生成的alterId,可以自行设置。
        }
      ]
    },
    "streamSettings": {
      "network": "ws",
      "wsSettings": {
        "path": "/daili/"   //此处为路径,需要和下面NGINX上面的路径配置一样
      }
    }
  }],
  "outbounds": [{
    "protocol": "freedom",
    "settings": {}
  },{
    "protocol": "blackhole",
    "settings": {},
    "tag": "blocked"
  }],
  "routing": {
    "rules": [
      {
        "type": "field",
        "ip": ["geoip:private"],
        "outboundTag": "blocked"
      }
    ]
  }
}

之后,转到宝塔管理界面,网站——你想要伪装的域名(比如博客名)——进入站点修改

#下方是v2ray代理
location /daili/
    {
    proxy_redirect off;
      proxy_pass http://127.0.0.1:65432;
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
    proxy_set_header Host $http_host;
    }

宝塔v2_1.png

修改之后,根据v2ray官方文档自行添加客户端配置即可。

https://toutyrater.github.io/prep/

最后修改:2024 年 02 月 14 日
如果觉得我的文章对你有用,请随意赞赏