Secure Internal Web Apps with Teleport Application Access

Put internal web apps like Grafana behind Teleport Application Access, with sign-in, MFA, role-based access and audit logs instead of a VPN.

Internal web applications such as Grafana dashboards, admin panels and CI consoles often end up behind a VPN, or worse, on a public IP with only the app's own password in front of them. Teleport Application Access offers another option: users sign in to Teleport with MFA, Teleport checks their roles on every request, and it records who opened which app. Nothing about the app has to change, and you don't need a VPN.

To put a web app behind Teleport:

  1. Create a Linux server with port 443 open, and point two DNS records at it.
  2. Install Teleport and configure it to get certificates from Let's Encrypt.
  3. Run the app and add it to Teleport's Application Service.
  4. Create a user, then open the app through Teleport.

This post walks through each step on a single DigitalOcean droplet, with Grafana as the example app.

What is Teleport Application Access?

Teleport is an access platform for servers, Kubernetes clusters, databases and web applications. It combines connectivity, authentication, authorisation and audit in one place, using short-lived certificates instead of shared passwords and keys.

Teleport Application Access overview
Teleport Application Access

A Teleport cluster has a few parts:

  • The Auth Service is the certificate authority.
  • The Proxy Service is the public entry point that users connect to.
  • Agent services connect individual resources to the cluster. For web apps, that agent is the Application Service.

When a user opens an app, the Proxy Service forwards the request to the Application Service. The Application Service checks a JSON Web Token (JWT) carrying the user's roles, signed by the Auth Service, before passing the request on to the app. Each app gets its own subdomain of your cluster, such as https://grafana.teleport.example.com.

Create a Server and DNS Records

I'm using a DigitalOcean droplet, but any Linux server with a public IP works. Choose the latest Ubuntu LTS image. Teleport's docs say 2 vCPUs and 1 GB of RAM is enough for testing; since Grafana runs on the same host here, I'd pick 2 GB. Add a DigitalOcean Cloud Firewall that allows inbound traffic on port 443 only. You can run the setup commands from the droplet's web console, or also allow SSH on port 22 while you set things up.

Teleport needs a domain name. Create two A records that point to the droplet's IP address:

RecordPurpose
teleport.example.comThe Teleport Proxy Service and Web UI
*.teleport.example.comOne subdomain for each web app you add to Teleport

Check that the records resolve with dig teleport.example.com before you continue, because Let's Encrypt needs them in the next step.

Install and Configure Teleport

Install Teleport with its install script. The version below was the latest when I updated this post; check Teleport's installation docs for the current one.

curl https://cdn.teleport.dev/install.sh | bash -s 18.11.10

Generate a configuration file. With --acme, Teleport gets a TLS certificate from Let's Encrypt for your cluster's domain, and later a separate certificate for each app's subdomain. The email address is for Let's Encrypt notifications.

sudo teleport configure -o file \
  --acme --acme-email=user@example.com \
  --cluster-name=teleport.example.com

Start Teleport and enable it at boot:

sudo systemctl enable teleport
sudo systemctl start teleport

Open https://teleport.example.com in a browser. You should see the Teleport welcome page, where you accept the Community Edition terms.

Run Grafana in a Docker Container

Install Docker and start Grafana. Publishing the port on 127.0.0.1 means Grafana only listens on the droplet itself, so the only way to reach it from outside is through Teleport.

sudo apt-get install -y docker.io
sudo docker run --detach --name grafana --publish 127.0.0.1:3000:3000 grafana/grafana

Teleport's docs also set Grafana's domain setting to your cluster's address:

sudo docker exec --user 0 grafana sed -i \
  's/;domain = localhost/domain = teleport.example.com/g' \
  /etc/grafana/grafana.ini
sudo docker restart grafana

Add Grafana to the Teleport Application Service

Because Grafana runs on the same host as the Teleport cluster, you can turn on the Application Service in the existing configuration. Add this to the end of /etc/teleport.yaml:

app_service:
  enabled: true
  apps:
  - name: grafana
    uri: http://localhost:3000

Then restart Teleport:

sudo systemctl restart teleport

If the app runs on a different server, you install Teleport there too and join it to the cluster with a short-lived token. Create the token with tctl tokens add --type=app, then generate that server's configuration with teleport configure --roles=app. Teleport's guide to protecting a web application covers this in detail.

Create a User and Open Grafana

Create a local user with Teleport's built-in access role, which can open any resource in the cluster:

sudo tctl users add --roles=access app-user

The command prints an invite link that's valid for one hour. Open it to set a password and enrol an MFA device; Teleport requires MFA by default and supports authenticator apps and hardware keys. For a real deployment, create roles that grant access to specific apps instead of using access for everyone.

After you sign in, Grafana appears in the list of resources in the Teleport Web UI. Click Launch to open it.

Grafana listed as an application in the Teleport Web UI
Teleport web applications

You can also go straight to https://grafana.teleport.example.com. If you aren't signed in to Teleport yet, it asks you to sign in first, then sends you on to Grafana.

Grafana sign-in page opened through Teleport
Grafana application login

Single Sign-On to the App with JWTs

Grafana still shows its own sign-in page, because Teleport doesn't pass your identity to off-the-shelf apps on its own. For apps you build yourself, you can use the JWTs Teleport sends. Teleport adds a signed JWT to each request in the Teleport-Jwt-Assertion header. Your app can verify the signature against Teleport's JSON Web Key Set at https://teleport.example.com/.well-known/jwks.json, read the user's identity and roles from the token, and sign the user in without a second password.

Beyond this walkthrough, Application Access can rewrite headers and redirects for apps that need it, and gives command-line access to internal APIs: tsh apps login grafana gets a short-lived certificate you can use with curl or scripts.

Frequently Asked Questions

Do I need a VPN with Teleport Application Access? No. Users reach apps through the Teleport Proxy Service over HTTPS on port 443, and only the Proxy Service needs to be reachable from the internet. The apps themselves can stay on private addresses.

Is Teleport free? Teleport Community Edition is free for individuals and for companies with fewer than 100 employees and less than $10 million in annual revenue. Larger companies need Teleport Enterprise, which also adds features such as SAML and OIDC single sign-on and Access Requests.

Why does Teleport need a wildcard DNS record? Teleport serves each app on its own subdomain, such as grafana.teleport.example.com. A wildcard record covers every app you add later, so you don't need a new DNS record each time.

Can the app run on a different server from Teleport? Yes. Install Teleport on the app's server, join it to the cluster with a join token, and run only the Application Service there.

Teleport Application Access applies the zero trust principles in NIST SP 800-207: every request is authenticated and authorised, whatever network it comes from. I covered the same approach for SSH in Remote Server Access with Teleport, and replacing a VPN with a Tailscale mesh network.

Subscribe to alphasec

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe