Skip to content

Connect a local Cloudflare tunnel to you network in a few easy steps

License

Notifications You must be signed in to change notification settings

stefanes/cloudflared

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Cloudflare tunnels with PowerShell

Connect a local Cloudflare tunnel to you network in a few easy steps.

1. Setup your domain

Setup your own domain name (e.g. that-is-a.win) to use the Clodflare nameservers, if you do aready not have one, you can get cheap domains from Porkbun.

Add your domain to Cloudflare and update the nameservers to the ones you received from Cloudflare.

2. Download cloudflared

Download and extract cloudflared from Cloudflare.

3. Run the script to connect your tunnel

To connect a tunnel routing the default set of services (see here):

& .\cloudflared\connect-tunnel.ps1 -CloudflaredPath 'C:\path\to\cloudflared.exe' -HostName 'that-is-a.win'

To route other services, provide your own services using the -DefaultServices parameter:

& .\cloudflared\connect-tunnel.ps1 -CloudflaredPath 'C:\path\to\cloudflared.exe' -HostName 'that-is-a.win' -Service 'http://192.168.2.100:8080' -DefaultServices @(
    @{
        domain  = 'www'
        service = 'http://192.168.2.100:8080'
    }
    @{
        domain  = 'router'
        service = 'http://192.168.2.1'
    }
)

Or include additional services (in addition to the default services) using the -AdditionalServices parameter:

& .\cloudflared\connect-tunnel.ps1 -CloudflaredPath 'C:\path\to\cloudflared.exe' -HostName 'that-is-a.win' -Service 'http://192.168.1.100:8080' -AdditionalServices @(
    @{
        domain  = 'something'
        service = 'http://192.168.1.254'
    }
)

Home Assistant

If using this with Home Assistant you need to do one more thing. Since Home Assistant blocks requests from unknown proxies/reverse proxies, you need to tell your instance to trust your local network by adding something like this to your configuration.yaml:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 192.168.1.0/24

About

Connect a local Cloudflare tunnel to you network in a few easy steps

Topics

Resources

License

Stars

Watchers

Forks