Setting up Teleport access using Cloudflare tunnel (cloudflared
)
#50346
webvictim
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This guide will describe how to set up Teleport traffic to ingress via Cloudflare tunnel (
cloudflared
), rather than forwarding a port from your external IP to the Teleport host.This setup is useful in situations where:
Notes
example.com
is my domainteleport.example.com
is where I want my Teleport server accessible on the internetlocalhost
on port 3080localhost
(stored at/var/lib/teleport/webproxy_cert.pem
by default) which you can tellcloudflared
to look forcloudflared
TLS verification is the easiest and quickest way to set this up for testingcertbot
or similar to get trusted TLS certs and providing them to Teleport using theproxy_service.https_keypairs
configurationNon-goals
teleport.example.com
(as the free wildcard certificate Cloudflare issues only covers one level, not two levels as inapp.teleport.example.com
)myteleport.com
) and then subdomains for each app (app.myteleport.com
)Teleport configuration
Teleport is installed straight onto a Raspberry Pi and uses the config file below. This guide assumes you have Teleport working correctly before attempting to configure Cloudflare.
/etc/teleport.yaml
:Config for Teleport agents joining remotely
Cloudflare configuration
cloudflared
on your server (you can use the same server that's running Teleport)teleport.example.com
in my case) and the hostname to send traffic to (localhost
if you're running on the same machine, or another hostname which can be resolved from thecloudflared
host if not)localhost
on
teleport.example.com
(replace with your own server name and domain)You should now be able to see your tunnel's ID in the UI:
Cloudflare should automatically add a CNAME record for
teleport.example.com
pointing to the ID of your tunnel. You can check by going back to the root of the Cloudflare admin console, opening your domain and going to "DNS -> Records" at the left-hand side:Notice that the record for
teleport
should be a proxied (orange-cloud) CNAME record pointing to<tunnel-id>.cfargotunnel.com
:At this point, you should be able to connect to Teleport via the hostname you configured and have all the traffic routed via Cloudflare tunnel.
Troubleshooting
If you get an error when trying to connect to your site, you can click on the Connector ID in the Cloudflare tunnel configuration to show the "Connector diagnostics" screen, which will also allow you to view live logs from the tunnel to view any errors.
You should also check your Teleport logs (
journalctl -fu teleport
) to see whether there are obvious errors.Make sure that your DNS server is returning the correct IPs (Cloudflare edge PoP IPs) rather than your home IP or NXDOMAIN.
Some browsers like Chrome can do internal caching of DNS records, so trying a different browser or device can help to flush out cached records. Assuming things work on another device, these cached records should clear themselves within a day or so.
If you haven't configured Teleport with
https_keypairs
or ACME support, double check that "No TLS Verify" is set to "on" as detailed above. Failure to do this will result incloudflared
being unable to connect to Teleport.Beta Was this translation helpful? Give feedback.
All reactions