Back to rankings

denuitt1/mhr-cfw

Python

A Domain-Fronting Relay that routes traffic though GAS (Google Apps Script) and forwards it to Cloudflare Workers. Designed to bypass DPI.

cloudflare-workersdomain-frontingdpidpi-bypassmitmproxygoogle-apps-scripthttpsni
Star Growth
Stars
4.4k
Forks
428
Weekly Growth
Issues
121
2k4k
Apr 26May 26Jun 26Jul 26
ArtifactsPyPIpip install mhr-cfw
README

MHR-CFW

MITM Domain-Fronted HTTP Relay + Cloudflare Worker Exit

GitHub

English Persian

How It Works

1 - GAS + Cloudflare Worker Exit

Client -> Local Relay -> Google/CDN Front -> GAS (Google Apps Script) Relay -> Cloudflare Worker -> Exit
            |
            +-> Shows www.google.com to network DPI filter

2 - GAS + Cloudflare Worker Middle + Self-Hosted Upstream Forwarder Relay Exit

Client -> Local Relay -> Google/CDN Front -> GAS (Google Apps Script) Relay -> Cloudflare Worker -> Self-Hosted Upstream Forwarder -> Exit
            |
            +-> Shows www.google.com to network DPI filter

In normal use, the browser sends traffic to the proxy running on your computer. The proxy sends that traffic through Google-facing infrastructure so the network only sees an allowed domain such as www.google.com. Your deployed relay then fetches the real website through cloudflare worker and sends the response back through the same path.

This means the filter sees normal-looking Google traffic, while the actual destination stays hidden inside the relay request.


How to Use

1 - Download project and extract

git clone https://github.com/denuitt1/mhr-cfw.git
cd mhr-cfw
pip install -r requirements.txt

Can't reach PyPI directly? Use this mirror instead:

pip install -r requirements.txt -i https://mirror-pypi.runflare.com/simple/ --trusted-host mirror-pypi.runflare.com

2 - Set Up the Cloudflare Worker (worker.js)

  1. Open Cloudflare Dashboard and sign in with your Cloudflare account.
  2. From the sidebar, navigate to Compute > Workers & Pages
  3. Click Create Application, Choose Start with Hello World and click on Deploy
  4. Click on Edit code and Delete all the default code in the editor.
  5. Open the worker.js file from this project (under deploy/), copy everything, and paste it into the Apps Script editor.
  6. Important: Change the worker on this line to the worker you created:
    const WORKER_URL = "myworker.workers.dev";
    
  7. Click Deploy.

3 - Set Up the Google Relay (Code.gs)

  1. Open Google Apps Script and sign in with your Google account.
  2. Click New project.
  3. Delete all the default code in the editor.
  4. Open the Code.gs file from this project (under deploy/), copy everything, and paste it into the Apps Script editor.
  5. Important: Change the password on this line to something only you know, also replace the worker url with your cloudflare worker:
    const AUTH_KEY = "your-secret-password-here";
    const WORKER_URL = "https://myworker.workers.dev";
    
  6. Click DeployNew deployment.
  7. Choose Web app as the type.
  8. Set:
    • Execute as: Me
    • Who has access: Anyone
  9. Click Deploy.
  10. Copy the Deployment ID (it looks like a long random string). You'll need it in the next step.

⚠️ Remember the password you set in step 3. You'll use the same password in the config file below.

4 - Run

Click on the run.bat file (on windows) or run.sh file (on linux) to start the relay.

If you're running for the first time it will prompt a setup wizard where you have to enter the AUTH_KEY and Google Apps Script Deployment ID. You should see a message saying the HTTP proxy is running on 127.0.0.1:8085

5 - Usage

We recommend using v2rayN client and configuring a socks5 proxy.

You can also use FoxyProxy's Chrome extension or Firefox extension to use this proxy in your browser.

6 - Test your connection

Open ipleak.net in your browser, you should see your ip address set as cloudflare's.

image

7 - Additional Usage Guides

Using the Proxy Inside a Virtual Machine

When you run a virtual machine (VM), it operates in an isolated network environment separate from the host. By default, the VM cannot directly access services running on localhost of the host machine — including this proxy.

To fix this, you need to find the gateway IP that your hypervisor assigns to the host, then use it instead of localhost when configuring the proxy inside the VM.

Example: VirtualBox (NAT mode)

The host is always reachable from inside the VM at 10.0.2.2. Set the proxy:

export http_proxy="http://10.0.2.2:8085"
export https_proxy="http://10.0.2.2:8085"
export all_proxy="socks5://10.0.2.2:8085"

To make this permanent, add the lines above to ~/.bashrc and run source ~/.bashrc.

Since this proxy performs SSL inspection, you may see certificate errors. Install the included ca.crt to fix them:

sudo cp ca.crt /usr/local/share/ca-certificates/ && sudo update-ca-certificates

Sharing the Proxy Over a Local Network (e.g. Mobile Devices)

You can use this proxy on your phone or any other device on the same network — no extra software needed.

1. Find your host IP

# Windows
ipconfig
 
# Linux / macOS
ip addr

Look for the IP of the adapter connected to your router (e.g. 192.168.1.8).

2. Forward the port (Windows only, if the service is bound to localhost)

Run CMD as Administrator:

netsh interface portproxy add v4tov4 listenaddress=192.168.1.8 listenport=8085 connectaddress=127.0.0.1 connectport=8085
netsh advfirewall firewall add rule name="Proxy 8085" dir=in action=allow protocol=TCP localport=8085

3. Configure proxy on your phone

Connect your phone to the same Wi-Fi, then set the proxy manually:

  • Host: your host IP (e.g. 192.168.1.8)
  • Port: 8085

On Android: Settings → Wi-Fi → Modify → Proxy → Manual
On iPhone: Settings → Wi-Fi → (network) → HTTP Proxy → Manual

4. Install the CA certificate

Transfer ca.crt to your phone, then:

  • Android: Settings → Security → Install a certificate → CA certificate
  • iPhone: Open the file → install profile → Settings → General → About → Certificate Trust Settings → enable it

Optional: Stable Exit IP via Upstream Forwarder

CAPTCHAs (Cloudflare Turnstile/bot challenge, reCAPTCHA, hCaptcha) bind tokens to the IP that solved the challenge. Cloudflare Workers exit through different edge IPs per request, so verification on the target site fails even when you solve the challenge. This optional add-on lets the Worker forward all fetch() calls through a small Node server you run on a VPS with a stable IP — giving the target site one consistent exit address.

When you need this

  • Sites behind Cloudflare's bot challenge keep looping you back to the challenge page.
  • Login forms reject you after solving a reCAPTCHA/hCaptcha.
  • You need cookie continuity across requests (e.g. cf_clearance).

If you don't hit these, leave it unconfigured — the Worker behaves exactly as before.

Why a separate server is required

Cloudflare Workers don't expose a stable outbound IP — fetch() exits through a rotating pool of Cloudflare edge IPs, which is exactly what breaks IP-bound CAPTCHA tokens. Cloudflare's static-egress options (BYOIP, Egress Workers) are Enterprise-tier, so a small VPS with a static IP is the practical workaround. The forwarder is just a thin proxy that re-issues the fetch() from a stable address.

1. Deploy the forwarder on a VPS

The reference implementation is deploy/upstream-forwarder/upstream_forwarder.js. It needs Node 18+ and no dependencies. Run it behind Caddy or nginx with TLS — the Worker rejects non-HTTPS forwarder URLs.

# On your VPS (Ubuntu/Debian example):
sudo apt install -y nodejs   # must be 18+
export AUTH_KEY="some-long-random-string-at-least-32-chars"
export PORT=8787
node deploy/upstream-forwarder/upstream_forwarder.js

Front it with Caddy for auto-TLS:

forwarder.example.com {
    reverse_proxy 127.0.0.1:8787
}

Quick smoke test:

curl -X POST https://forwarder.example.com/fwd \
  -H "x-upstream-auth: $AUTH_KEY" \
  -H "content-type: application/json" \
  -d '{"u":"https://httpbin.org/ip","m":"GET","h":{}}'

The decoded response body should show the VPS's IP.

2. Wire the Worker to the forwarder

In the Cloudflare dashboard → your Worker → Settings → Variables and Secrets:

Name Type Value
UPSTREAM_FORWARDER_URL Secret https://forwarder.example.com/fwd
UPSTREAM_AUTH_KEY Secret the same AUTH_KEY you set on the VPS
UPSTREAM_FAIL_MODE Variable closed (default) — return 502 on forwarder failure. Use open to fall back to direct fetch.
UPSTREAM_TIMEOUT_MS Variable (optional) default 25000

Save and redeploy the Worker.

3. Verify

Browse https://httpbin.org/ip through the proxy — you should see the VPS's IP, not Cloudflare's. Then revisit a CAPTCHA-protected site that wasn't working — the challenge should now validate.

The forwarder must require auth. Without AUTH_KEY it refuses to start. Anyone with the URL and key can use it as a relay, so keep both secret.

4. Scope the forwarder to specific hosts (optional)

By default every request the Worker handles routes through the forwarder, so unrelated traffic also burns VPS bandwidth. To send only the sites that need a stable exit IP through the VPS, list them in forwarder_hosts in config.json — same syntax as bypass_hosts (exact hostname or .suffix). Anything not matched falls back to direct fetch() on the Worker.

{
   ...
   "forwarder_hosts": [
       "example.com",
       ".cf-protected-suffix"
   ]
   ...
}

Leave the list empty (or remove the key) to keep the historical "forward everything" behavior.


Disclaimer

MHR-CFW is provided for educational, testing, and research purposes only.

  • Provided without warranty: This software is provided "AS IS", without express or implied warranty, including merchantability, fitness for a particular purpose, and non-infringement.
  • Limitation of liability: The developers and contributors are not responsible for any direct, indirect, incidental, consequential, or other damages resulting from the use of this project or the inability to use it.
  • User responsibility: Running this project outside controlled test environments may affect networks, accounts, proxies, certificates, or connected systems. You are solely responsible for installation, configuration, and use.
  • Legal compliance: You are responsible for complying with all local, national, and international laws and regulations before using this software.
  • Google services compliance: If you use Google Apps Script or other Google services with this project, you are responsible for complying with Google's Terms of Service, acceptable use rules, quotas, and platform policies. Misuse may lead to suspension or termination of your Google account or deployments.
  • License terms: Use, copying, distribution, and modification of this software are governed by the repository license. Any use outside those terms is prohibited.

Contributors


Sources


License

MIT

Related repositories
honojs/hono

Web framework built on Web Standards

TypeScriptnpmMIT Licensecloudflareweb-framework
hono.dev
31.4k1.2k
supermemoryai/supermemory

Memory and context engine + app that is extremely fast, scalable, and can be run fully locally. The Memory API for the AI era.

TypeScriptnpmMIT Licensecloudflare-pagescloudflare-workers
supermemory.ai/docs
28.5k2.5k
kriasoft/react-starter-kit

Modern React starter kit with Bun, TypeScript, Tailwind CSS, tRPC, Stripe, and Cloudflare Workers. Production-ready monorepo for building fast web apps.

TypeScriptnpmMIT Licensereactboilerplate
reactstarter.com
23.6k4.2k
yonggekkk/Cloudflare-vless-trojan

CF-workers/pages代理脚本:支持Vless-ws(tls)、Trojan-ws(tls);Socks5/http本地代理脚本:可选ECH-TLS、普通TLS、无TLS三种代理模式

JavaScriptnpmcdnvless
ygkkk.blogspot.com/2023/07/cfworkers-vless.html
15.6k9.6k
maillab/cloud-mail

A Cloudflare-based email service | 基于 Cloudflare 的邮箱服务 | Cloudflare Email 邮箱 Mail

JavaScriptnpmMIT Licenseemailcloudflare-email
skymail.ink
12.6k18.3k
dreamhunter2333/cloudflare_temp_email

CloudFlare free temp domain email 免费收发 临时域名邮箱 支持附件 IMAP SMTP TelegramBot

TypeScriptnpmMIT Licensecloudflare-emailcloudflare-pages
mail.awsl.uk
10.6k7.2k
cloudflare/moltworker

Run OpenClaw, (formerly Moltbot, formerly Clawdbot) on Cloudflare Workers

TypeScriptnpmApache License 2.0ai-agentscloudflare-workers
blog.cloudflare.com/moltworker-self-hosted-ai-agent/
9.9k1.7k
cmliu/CF-Workers-docker.io

这个项目是一个基于 Cloudflare Workers 的 Docker 镜像代理工具。它能够中转对 Docker 官方镜像仓库的请求,解决一些访问限制和加速访问的问题。

JavaScriptnpmcloudflare-pagescloudflare-workers
docker.fxxk.dedyn.io
9.2k10.6k
zizifn/edgetunnel

Running V2ray inside edge/serverless runtime

JavaScriptnpmGNU General Public License v2.0cloudflare-workersv2ray
8.9k48.2k
webstudio-is/webstudio

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

TypeScriptnpmGNU Affero General Public License v3.0accessibilitycloudflare
webstudio.is
8.7k1.6k
yonggekkk/Cloudflare_vless_trojan

CF-workers/pages代理脚本【Vless与Trojan】,支持一键自建proxyip与CF反代IP,CF优选官方IP三地区应用脚本,自动输出美、亚、欧最佳优选IP

JavaScriptnpmcdnvless
ygkkk.blogspot.com/2023/07/cfworkers-vless.html
7.9k6.4k
panva/jose

JWA, JWS, JWE, JWT, JWK, JWKS for Node.js, Browser, Cloudflare Workers, Deno, Bun, and other Web-interoperable runtimes

TypeScriptnpmMIT Licensejosejwa
7.7k375