MENU

Typecho + Nginx + V2ray(Ws+VMess)分流规则

November 21, 2022 • Read: 2746 • 随心笔记

最近博客的阿里服务器到期,本来想着迁到腾讯,但是因为备案问题,迫不得已只能先迁移到香港,等后面有空再慢慢搞定这个备案问题。

于是入了一款阿里的轻量,令我意外的是,阿里香港轻量国内御三家的去程全是精品网 (CN2 CMI 9929),三网回程是普通的 4837 线路。

去程就不放了,回程测试:

阿里轻量回程路由.png

望着每个月 2T 的流量,一个博客肯定用不了,30 兆的宽带日常爬爬也足够了,于是想着干脆搭个节点避免浪费,而且刚好和博客放在一起;利用博客的 Nginx + tls 作为入口,再利用 WS 分流到另外一台服务器。

理想是美好的,但是 Typecho 的伪静态规则会导致 nginx location 分流失效,于是测试了半天,正确的配置如下。

宝塔

  • location / {
  • # V2Ray ws
  • location /login {
  • proxy_redirect off;
  • proxy_pass http://127.0.0.1:8443;
  • proxy_http_version 1.1;
  • proxy_set_header Upgrade $http_upgrade;
  • proxy_set_header Connection "upgrade";
  • proxy_set_header Host $http_host;
  • # Show realip in v2ray access.log
  • proxy_set_header X-Real-IP $remote_addr;
  • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  • }
  • # typecho
  • if (!-e $request_filename) {
  • rewrite ^(.*)$ /index.php$1 last;
  • }
  • }

V2ray

  • {
  • "log": {
  • "access": "/var/log/v2ray/access.log",
  • "error": "/var/log/v2ray/error.log",
  • "loglevel": "warning"
  • },
  • "inbounds": [
  • {
  • "port": 8443,
  • "protocol": "vmess",
  • "settings": {
  • "clients": [
  • {
  • "id": "fe911926-888f-99a4-118e-d1c17bdcb76b",
  • "alterId": 0
  • }
  • ],
  • "disableInsecureEncryption": true
  • },
  • "streamSettings": {
  • "network": "ws",
  • "wsSettings": {
  • "path": "/login",
  • "maxEarlyData": 1024
  • }
  • }
  • }
  • ],
  • "outbounds": [
  • {
  • "protocol": "freedom"
  • }
  • ]
  • }

参考文章