利用BPB Panel 部署Cloudflare Workers 或 Pages 的代理面板项目,可以轻松建立免费 VPN,因CF对代理项目审查较严格,所以需要需要对源码进行自定义加密混淆,生成不同的混淆代码,绕过CF的限制。

方法一

准备工作
Github帐号;cloudflare账号;域名(收费或免费域名)

Github部署

  1. 新建github仓库:把BPB panel项目代码同步到仓库。
  2. 配置github Actions: 在仓库目录下创建.github/workflows文件夹,并创建Obfuscate.yml文件。
name: Build Obfuscate BPB worker  # 工作流名称:构建并混淆BPB worker

on:
  push:
    branches:
      - main  # 当main分支有push时触发
  schedule:
    - cron: '3 1,13 * * *'  # 每天UTC时间1:03和13:03自动运行(北京时间9:03和21:03)
  workflow_dispatch:        # 保留手动触发按钮

permissions:
  contents: write  # 授予写入仓库内容的权限(用于后续git push)

jobs:
  build:
    runs-on: ubuntu-latest  # 使用最新版Ubuntu系统作为运行环境

    steps:
      # 第一步:检出代码
      - name: Check out the code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0  # 获取完整git历史记录(用于后续git diff比较)

      # 第二步:设置Node.js环境
      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "latest"  # 使用最新版Node.js

      # 第三步:安装依赖
      - name: Install dependencies
        run: |
          npm install -g javascript-obfuscator  # 全局安装JS混淆工具
          sudo apt-get install -y unzip curl    # 安装解压工具和curl(用于下载文件)

      # 第四步:下载最新worker并处理
      - name: Download and extract latest BPB worker
        run: |
          # 通过GitHub API获取最新版worker.zip的下载链接
          LATEST_URL=$(curl -s https://api.github.com/repos/bia-pain-bache/BPB-Worker-Panel/releases/latest | grep "browser_download_url.*worker.zip" | cut -d '"' -f 4)
          
          # 下载文件并保存为worker.zip
          wget "$LATEST_URL" -O worker.zip
          
          # 解压并将内容直接输出到origin.js(不依赖原文件名)
          unzip -p worker.zip > origin.js
          
          # 使用javascript-obfuscator混淆代码
          javascript-obfuscator origin.js --output _worker.js \
            --compact true \                  # 压缩代码
            --identifier-names-generator hexadecimal \  # 变量名转为16进制
            --rename-globals true \            # 重命名全局变量
            --string-array true \              # 加密字符串
            --string-array-encoding 'base64' \ # 使用base64编码
            --string-array-threshold 0.75 \    # 75%以上的字符串会被加密
            --transform-object-keys true \     # 混淆对象键名
            --self-defending false \           # 关闭反调试(可根据需要开启)
            --simplify true                   # 简化代码逻辑

      # 第五步:提交变更
      - name: Commit and push changes
        run: |
          # 配置git用户信息(使用GitHub Actions的机器人账号)
          git config --global user.name "github-actions[bot]"
          git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
          
          # 添加要提交的文件
          git add origin.js _worker.js
          
          # 检查文件是否有变化
          if git diff-index --quiet HEAD --; then
            echo "没有检测到文件变化,跳过提交"
          else
            # 提交变更(包含时间戳)
            git commit -m ":arrow_up: 自动更新worker文件 [$(date +'%Y-%m-%d %H:%M:%S')]"
            
            # 同步远程变更(避免冲突)
            git pull --rebase origin main
            
            # 推送变更到main分支
            git push origin main
          fi

Github仓库通过Obfuscate.yml自动下载BPB源代码,并执行混淆。

假如失效,可以进入BPB panel大佬项目地址重新更新download地址

Cloudflare 部署
•创建pages:点击workers和pages,选择pages部署。连接github仓库,选择新建的项目仓库,然后点击部署。
•绑定自定义域名:以防止page分配的域名被屏蔽。
•设置变量:
UUID:使用UUID在线生成器
PROXY_IP:从随机代理ip站点获取
TR_PASS:随便写个密码
•绑定KV命名空间:名称随便但不能含有bpb等敏感词,绑定的是小写kv
•重试部署pages
BPB面板设置
•部署成功后,打开浏览器输入:https://[自定义域名]或者你的项目地址,后面加上/panel检查是否能正常访问BPB面板.
•修改BPB面板密码
•配置BPB面板参数
2025-04-18T04:55:30.png
2025-04-18T04:57:05.png
常用IP获取方式
cleanIP/优选IP:地址1 地址2 地址3 优选域名
PROXYIP:点击进入1 点击进入2
优选域名
本地优选ip windows版,下载地址
节点测试
在V2rayN上使用演示

Proxy IPs / Domains 获取地址:这里

参考大佬视频教程文字教程

方法二

(也是自己在用,自带混淆以后也可套用这个)
在根目录创建项目,然后添加.github/workflows/Obfuscate.yml文件,输入以下代码
name: Build Obfuscate my_tro

on:
  push:
    branches:
      - main
  schedule:
    - cron: "0 3 * * *"  # 每天凌晨3点自动运行
  workflow_dispatch:     # 支持手动运行

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Check out the code
        uses: actions/checkout@v4

      - name: Set up Node.js
        uses: actions/setup-node@v4
        with:
          node-version: "latest"

      - name: Install dependencies
        run: |
          npm install -g javascript-obfuscator
          sudo apt-get install -y unzip

      - name: Download and extract latest my_tro worker
        run: |
          wget https://raw.githubusercontent.com/camel52zhang/my_tro/refs/heads/main/_worker.js
          mv _worker.js origin.js

      - name: Clean existing obfuscated files  # 新增清理步骤
        run: |
          rm -f _worker.js*

      - name: Obfuscate my_tro worker js
        run: |
          javascript-obfuscator origin.js --output _worker.js \
          --compact true \
          --identifier-names-generator hexadecimal \
          --rename-globals true \
          --string-array true \
          --string-array-encoding 'base64' \
          --string-array-threshold 0.75 \
          --transform-object-keys true \
          --self-defending false \
          --simplify true

      - name: 提交更改
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          branch: main
          commit_message: ':arrow_up: update latest my_tro'
          commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'
          push_options: '--set-upstream'

方法三

在根目录创建项目,然后添加.github/workflows/update-worker.yml文件,输入以下代码

name: Auto Update Worker

on:
  push:
    branches:
      - main
  schedule:
    - cron: '3 1,13 * * *'  # 每天 UTC 时间 1:03 和 13:03 自动运行(北京时间 9:03 和 21:03)
  workflow_dispatch:     # 支持手动运行

permissions:
  contents: write

jobs:
  update:
    runs-on: ubuntu-latest
    steps:
      - name: 初始化仓库
        uses: actions/checkout@v4

      - name: 获取当前本地版本
        id: get_local_version
        run: |
          echo -e "\033[34m[获取本地版本]\033[0m"
          if [ -f version.txt ]; then
            LOCAL_VERSION=$(cat version.txt)
            echo "当前本地版本: $LOCAL_VERSION"
          else
            echo "首次同步,没有本地版本。"
            LOCAL_VERSION=""
          fi
          echo "LOCAL_VERSION=$LOCAL_VERSION" >> $GITHUB_ENV

      - name: 获取最新 Release 信息
        id: get_release
        run: |
          echo -e "\033[34m[获取最新 Release]\033[0m"
          API_URL="https://api.github.com/repos/bia-pain-bache/BPB-Worker-Panel/releases"
          RESPONSE=$(curl -s "$API_URL")
          LATEST_RELEASE=$(echo "$RESPONSE" | jq -r '.[0]')
          TAG_NAME=$(echo "$LATEST_RELEASE" | jq -r '.tag_name')
          DOWNLOAD_URL=$(echo "$LATEST_RELEASE" | jq -r '.assets[] | select(.name == "worker.zip") | .browser_download_url')

          if [ -z "$DOWNLOAD_URL" ] || [ "$DOWNLOAD_URL" == "null" ]; then
            echo -e "\033[31m未找到 worker.zip,退出!\033[0m"
            exit 1
          fi

          echo "最新版本号: $TAG_NAME"
          echo "DOWNLOAD_URL=$DOWNLOAD_URL" >> $GITHUB_ENV
          echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV

      - name: 判断是否需要更新
        id: check_update
        run: |
          echo -e "\033[34m[判断是否需要更新]\033[0m"
          if [ "$LOCAL_VERSION" = "$TAG_NAME" ]; then
            echo -e "\033[32m已经是最新版本,无需更新。\033[0m"
            echo "UPDATE_NEEDED=false" >> $GITHUB_ENV
          else
            echo -e "\033[33m发现新版本,需要更新!\033[0m"
            echo "UPDATE_NEEDED=true" >> $GITHUB_ENV
          fi

      - name: 如果需要,清理旧文件并下载新版本
        if: env.UPDATE_NEEDED == 'true'
        run: |
          echo -e "\033[34m[清理旧文件]\033[0m"
          rm -rf ./*
          echo -e "\033[34m[下载最新 worker.zip]\033[0m"
          wget -O worker.zip "$DOWNLOAD_URL"
          echo -e "\033[34m[解压 worker.zip]\033[0m"
          unzip worker.zip
          echo -e "\033[34m[删除 worker.zip]\033[0m"
          rm worker.zip
          echo -e "\033[34m[记录新版本号]\033[0m"
          echo "$TAG_NAME" > version.txt

      - name: 提交更改
        if: env.UPDATE_NEEDED == 'true'
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "🔄 自动同步最新 Worker 版本:${{ env.TAG_NAME }}"
          commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
          push_options: --force

发表评论