GCP 免费实例使用 Cloudflare 服务的思路整理

背景

GCP 免费实例提供 200GiB 标准层级流量,但到 Cloudflare CDN 的流量单独收费。为了绕过付费墙使用 Cloudflare 的服务,我们可以通过 Proton 使用 Cloudflare WARP。本文将介绍如何通过防火墙封掉各大 CDN 的 IP,再通过代理访问 Cloudflare 的服务。

步骤

  1. 下载 Proton 的 WireGuard 配置

前往 Proton 下载 WireGuard 配置文件,选择延迟低的 endpoint。

  1. 安装 WireGuard(以 Debian 为例)
sudo apt install wireguard
  1. 配置 wg0(Proton 隧道)
sudo nano /etc/wireguard/wg0.conf

将 Proton 提供的配置粘贴进去,修改 AllowedIPs 行为:

AllowedIPs = 2606:4700:d0::a29f:c001/128

这一步只让 WARP 的 endpoint 地址走 Proton 隧道。

  1. 下载并注册 wgcf
wget -O wgcf https://github.com/ViRb3/wgcf/releases/download/v2.2.30/wgcf_2.2.30_linux_amd64 && chmod +x wgcf
./wgcf register
./wgcf generate
  1. 配置 wg1(WARP 隧道)
nano wgcf-profile.conf

AllowedIPsEndpoint 改为:

AllowedIPs = ::/0
Endpoint = [2606:4700:d0::a29f:c001]:2408

拷贝到 WireGuard 目录:

sudo cp wgcf-profile.conf /etc/wireguard/wg1.conf
  1. 启动隧道并添加默认路由
sudo wg-quick up wg0
sudo wg-quick up wg1
sudo ip -6 route add default dev wg1
  1. 验证
curl https://cloudflare.com/cdn-cgi/trace

输出中看到 warp=on 即表示成功。

后续可以做什么

用 Cloudflare Tunnel 建站

  1. 防火墙 block 掉所有 Cloudflare IPv4
  2. 安装并运行 cloudflared,用 tunnel 建站

流量路径:

GCP &LT--> Proton &LT--> Cloudflare

这种情况下 wg1 可以不启用,把 IPv6 默认路由改到 wg0 即可。wg1 在本文只是演示"通过 Proton 使用 WARP",Proton 本身也支持 IPv6。

传统回源 CDN 模式

理论上可以用 NAT64,但性能较差,也不是运营 NAT64 组织的本意,不建议。

标签: none

评论已关闭