Cloudflare Workers Local Dev with Wrangler and Caddy
Preface
As is well known, when deploying projects on CloudFlare Workers, the 1101 error may be triggered due to keywords.
Of course, the community already has mature code obfuscation solutions.
However, for better debugging and development, it's best to have a development environment that is not interfered with by CloudFlare.
CloudFlare officially provides a locally running Worker environment solution: Wrangler V3
Install Wrangler V3
Refer to the official documentation https://developers.cloudflare.com/workers/wrangler/install-and-update/
Use nvm to install node.js npm
Refer to the official documentation https://github.com/nvm-sh/nvm?tab=readme-ov-file#install--update-script
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install nodeCheck node and npm
node -v npm -v
Use npm to install Wrangler
npm install -g wrangler
Start a worker.js
Create a working directory
mkdir cfworker cd $_
Download the unobfuscated script from Joey's cfnew to the working directory just created
(just as an example, no specific meaning)
wget https://github.com/byJoey/cfnew/raw/refs/heads/main/%E6%98%8E%E6%96%87%E6%BA%90%E5%90%97 -O worker.js
Use Wrangler to start worker.js
npx wrangler dev worker.js
You can see it started successfully. And testing locally with curl can get HTTP data.
Use caddy to attach a domain
First set the domain resolution wr.icdyct.netlib.re
Install caddy using the official script
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg chmod o+r /etc/apt/sources.list.d/caddy-stable.list sudo apt update sudo apt install caddy
Caddyfile attach domain, note which port wrangler uses when starting (in the example above it's 8788 )
wr.icdyct.netlib.re { reverse_proxy localhost:8788 }
Use a browser to access wr.icdyct.netlib.re
The page displays normally
Try with UUID in the path
The page displays normally
Test Business Functions
Try to get node links from the subscription link
curl -L https://wr.icdyct.netlib.re/351c9981-04b6-4103-aa4b-864aa9c91469/sub | base64 -d
Take the first one
vless://351c9981-04b6-4103-aa4b-864aa9c91469@wr.icdyct.netlib.re:443?encryption=none&security=tls&sni=wr.icdyct.netlib.re&fp=chrome&type=ws&host=wr.icdyct.netlib.re&path=%2F%3Fed%3D2048#%E5%8E%9F%E7%94%9F%E5%9C%B0%E5%9D%80-443-WS-TLS
Find a proxy client to try
Functions work normally
Test with curl in cmd
curl -x socks5h://127.0.0.1:10808 google.com
Functions work normally

========




