* docs: add GitHub Actions tunnel general documentation README.md * docs: add cloudflared quick tunnel guide * Add: add cloudflared quick tunnel workflow * docs: add ngrok tunnel guide * Add: add ngrok tunnel workflow * fix: Update cloudflared-quick.md to add link to related yml file * fix: Update ngrok.md to add related file link * docs: add cloudflared named tunnel guide * Add: add cloudflared named workflow
5.9 KiB
cloudflared Named Tunnel
Run a Full tunnel with a permanent, unchanging URL using a Cloudflare
account and a custom domain. The tunnel URL never changes between restarts —
configure CodeFull.gs once and only re-trigger the workflow when needed.
Prerequisites
- A GitHub account (free)
- A Cloudflare account with a domain
cloudflaredinstalled on your local machine for one-time setupCodeFull.gsdeployed as a Google Apps Script Web App
One-Time Local Setup
These steps are performed once on your local machine. They create a named tunnel on Cloudflare and route your domain to it.
Step 1: Install cloudflared
Linux (Debian/Ubuntu):
curl -L --output cloudflared.deb \
https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64.deb
sudo dpkg -i cloudflared.deb
macOS:
brew install cloudflared
Windows: Download the installer from the cloudflared releases page.
Step 2: Authenticate with Cloudflare
cloudflared tunnel login
This opens a browser window. Select your domain and authorize.
Step 3: Create a Named Tunnel
cloudflared tunnel create my-tunnel
This outputs a tunnel ID (a UUID) and creates a credentials file at:
~/.cloudflared/<TUNNEL_ID>.json
Copy the tunnel ID — you will need it later.
Step 4: Route Your Domain
cloudflared tunnel route dns my-tunnel tunnel.yourdomain.com
Replace tunnel.yourdomain.com with the actual subdomain you want to use.
This creates a DNS record on Cloudflare pointing to your tunnel.
Step 5: Get the Credentials File
cat ~/.cloudflared/<TUNNEL_ID>.json
Copy the entire JSON output. You will use this as the
CLOUDFLARE_TUNNEL_CREDENTIALS secret in GitHub Actions.
GitHub Setup
Step 6: Create the Repository
If you already have a repository from another method, you can reuse it. Otherwise:
- Go to github.com and sign in
- Click the + icon in the top-right corner, then New repository
- Enter a repository name (e.g.,
my-tunnel) - Select Private (recommended — keeps your secrets secure)
- Click Create repository
Step 7: Add the Secrets
-
In your repository, go to Settings > Secrets and variables > Actions
-
Click New repository secret and add each of the following:
Name Value TUNNEL_AUTH_KEYA strong password. You will also set this in CodeFull.gs.CLOUDFLARE_TUNNEL_IDThe tunnel ID from Step 3. CLOUDFLARE_TUNNEL_HOSTNAMEThe subdomain you configured in Step 4 (e.g., tunnel.yourdomain.com).CLOUDFLARE_TUNNEL_CREDENTIALSThe entire JSON contents of the credentials file from Step 5. -
Click Add secret for each
Step 8: Add the Workflow
- In your repository, go to the Actions tab
- Click New workflow
- Click the set up a workflow yourself link
- Delete the default content and paste the contents of
cloudflared-named.yml[here] - Click Commit changes..., add a commit message, then click Commit changes
The workflow file will be saved to .github/workflows/cloudflared-named.yml.
Step 9: Run the Workflow
- Go to the Actions tab
- Select Full Tunnel (cloudflared Named) from the left sidebar
- Click Run workflow > Run workflow
The workflow will start immediately.
Step 10: Configure CodeFull.gs
Open CodeFull.gs in the Google Apps Script editor and update these constants:
const TUNNEL_SERVER_URL = "https://tunnel.yourdomain.com";
const TUNNEL_AUTH_KEY = "the-secret-you-set-in-step-7";
Deploy: Deploy > New Deployment > Web App.
Copy the new Deployment ID and update your mhrv-rs config.
This step is performed only once. The tunnel URL never changes between restarts.
Step 11: Verify
Use mhrv-rs test or visit https://ipleak.net through your proxy.
You should see a Cloudflare IP address.
How It Works
- GitHub Actions starts a Docker container running
mhrv-tunnel-nodeon port8080 cloudflaredconnects to Cloudflare using the named tunnel credentials- Cloudflare routes traffic from your custom domain to the runner through a secure, persistent tunnel
CodeFull.gsforwards tunnel operations to your custom domain over HTTPS- The runner stays alive for 6 hours, then shuts down automatically
- On restart, the same domain routes to the new runner — no configuration changes needed
Restarting the Tunnel
The tunnel shuts down after 6 hours. To start a new session:
- Go to the Actions tab
- Select Full Tunnel (cloudflared Named)
- Click Run workflow > Run workflow
That is all — the URL is permanent so CodeFull.gs does not need to be updated.
For automatic restarts every 6 hours, add a schedule trigger to the workflow:
on:
workflow_dispatch:
schedule:
- cron: '0 */6 * * *'
Limitations
- Requires a one-time local setup with
cloudflaredCLI - Requires a Cloudflare account with a domain
- 6-hour maximum per session (GitHub Actions limit)
Troubleshooting
| Problem | Solution |
|---|---|
cloudflared tunnel login fails |
Ensure your browser can reach dash.cloudflare.com. You may need to use a proxy or alternative network for this step. |
cloudflared tunnel create fails |
Verify you are authenticated. Run cloudflared tunnel login again. |
| Workflow fails at Docker step | GitHub Actions may be pulling the image for the first time. Wait 2-3 minutes and retry. |
cloudflared fails to connect |
Verify all four secrets are set correctly. Check that CLOUDFLARE_TUNNEL_CREDENTIALS contains valid JSON. |
CodeFull.gs returns 502 or timeout |
Verify the workflow is still running. Check that TUNNEL_AUTH_KEY matches in both the secret and CodeFull.gs. Ensure the DNS record was created in Step 4. |