Skip to content

Instantly share code, notes, and snippets.

@phlinhng
Last active February 22, 2024 07:33
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save phlinhng/c11c1268748874982fa6596fb0a4992a to your computer and use it in GitHub Desktop.
Save phlinhng/c11c1268748874982fa6596fb0a4992a to your computer and use it in GitHub Desktop.
利用 v2ray-core / xray-core 的任意門協議解鎖流媒體

V2Ray 白話文教學介紹了如何利用 V2Ray 的路由功能將特定網站(例如 Netflix)的流量經過 Shadowsocks 轉到另一台機器上,達成解鎖流媒體的方法。 事實上,可以利用 V2Ray 的任意門協議直接將流量轉發到落地機上,進一步減少使用代理協議產生的開銷,以下為做法。

假設不能看奈飛的機器為 VPS A,可以看奈飛的機器為 VPS B。

基本配置

  • VPS A: 開兩個 freedom outbound,一個給 80 端口,一個給 443 端口,並配置對應的路由規則
  • VPS B: 開兩個 dokodemo-door inbound,一個給 80 端口,一個給 443 端口,兩個 inbound 都要設置 sniffing,並配置對應的路由規則

VPS A 設置

{
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    },
    {
      "tag": "netflix-80",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "AsIs",
        "redirect": "10.128.0.8:8080" // VPS B 的 IP
      }
    },
    {
      "tag": "netflix-443",
      "protocol": "freedom",
      "settings": {
        "domainStrategy": "AsIs",
        "redirect": "10.128.0.8:8443" // VPS B 的 IP
      }
    }
  ],
  "routing": {
    "domainStrategy": "AsIs",
    "rules": [
      {
        "type": "field",
        "port": 80,
        "domain": [
          "ip.sb",
          "geosite:netflix"
        ],
        "outboundTag": "netflix-80"
      },
      {
        "type": "field",
        "port": 443,
        "domain": [
          "ip.sb",
          "geosite:netflix"
        ],
        "outboundTag": "netflix-443"
      }
    ]
  }
 }

這裡加上 ip.sb 的域名是方便測試重定向是否成功

VPS B 設置

{
  "inbounds": [
    {
      "listen": "0.0.0.0",
      "port": 8080,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "0.0.0.0",
        "port": 80,
        "network": "tcp",
        "followRedirect": false
      },
      "sniffing": {
        "enabled": true,
        "destOverride": ["http"]
      },
      "tag": "unblock-80"
    },
    {
      "listen": "0.0.0.0",
      "port": 8443,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "0.0.0.0",
        "port": 443,
        "network": "tcp",
        "followRedirect": false
      },
      "sniffing": {
        "enabled": true,
        "destOverride": ["tls"]
      },
      "tag": "unblock-443"
    }
  ],
  "outbounds": [
    {
      "tag": "direct",
      "protocol": "freedom",
      "settings": {}
    }
  ],
  "routing": {
    "rules": [{
      "type": "field",
      "inboundTag": ["unblock-80", "unblock-443"],
      "outboundTag": "direct"
    }]
  }
}

如果想指定 Netflix 走 IPv6,需要在 freedom 的 settings 裡加上 "domainStrategy": "useIPv6"

測試解鎖效果

此時掛 VPS A 的梯子訪問 ip.sb,如果順利的話應該會顯示 VPS B 的 IP,訪問 Netflix 也會顯示 VPS B 應該看到的內容。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment