Skip to content

A cloudflared automation script that dynamically updates the configuration to a specified port and initiates the tunnel, enabling live port forwarding while maintaining the chosen domain.

Notifications You must be signed in to change notification settings

neuroborus/cloudflared-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Cloudflared Alias

Small helper script to quickly switch the local port used by a Cloudflare Tunnel and start the tunnel with a single command.

The script:

  1. Updates the service: http://localhost:<port> line in your Cloudflare config.
  2. Prints the effective port and hostname.
  3. Kills any running cloudflared processes.
  4. Starts the specified tunnel with the updated config.

Create an alias:

  1. echo 'alias port-forward="$HOME/.cloudflared/run-tunnel.sh"' >> ~/.bashrc (or your path to the script)
  2. source ~/.bashrc

Then use:

  • port-forward 3000

Requirements

  • Linux (tested on Ubuntu).
  • bash
  • cloudflared
  • A configured named tunnel (e.g. localhost-tunnel).
  • Config file at:
~/.cloudflared/config.yml

With structure similar to:

tunnel: localhost-tunnel
credentials-file: /home/USER/.cloudflared/<uuid>.json

ingress:
  - hostname: localhost.hasso.tech
    service: http://localhost:3000
  - service: http_status:404

Cloudflare Cache Rule (example: localhost.hasso.tech)

Replace hasso.tech / localhost.hasso.tech with your own zone and hostname.

  1. In your zone (e.g. hasso.tech) go to: Rules → Cache Rules → Create rule.
  2. Rule name: no-cache localhost
  3. When incoming requests match:
    • Condition:
      • Field: Hostname
      • Operator: equals
      • Value: localhost.hasso.tech ← your hostname
  4. Then… (action):
    • Action: Cache
    • Setting: Bypass cache (or Cache level: Bypass in the old UI)
  5. Save and ensure the rule is Enabled.

About

A cloudflared automation script that dynamically updates the configuration to a specified port and initiates the tunnel, enabling live port forwarding while maintaining the chosen domain.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages