⭐ Core project · #3

🚪 Selective public exposure (Funnel)

Open one specific service to the entire internet — safely. We walk a real decision tree before turning it on, then expose a webhook endpoint as the example use case.

⭐ Core Security Intermediate ~1 hr Prereqs: M4L4 (Funnel)

Why this project

Sometimes you genuinely need public exposure: a webhook receiver from GitHub or Stripe, a demo URL to share with a non-tailnet user, a public-facing webhook your home automation triggers. Funnel makes this trivial. So trivial it's easy to do wrong.

The goal of this project is to build the discipline before the muscle: know before you turn on Funnel whether the service you're exposing is actually safe to publish. We pair the technical setup with a decision tree so you don't hand the internet a bad URL.

Who this helps

What you get

PUBLIC INTERNET TAILSCALE EDGE YOUR HOME 🐙 GitHub signed payloads 👀 visitor unauth'd 🦹 attacker unsigned Tailscale Funnel · Edge + DERP relay terminates HTTPS · forwards to your home 🪝 webhook receiver · port 9000 verifies HMAC signature · returns 200 / 401 ✓ signed → 200 ✗ unsigned → 401 ⚠ public is fine here only because the receiver itself rejects unauthenticated requests

Funnel lets the public hit your URL — but the application layer (HMAC signature check) decides who actually gets a 200. That's why this is safe; that's why the decision tree exists.

Prerequisites

Mental model

Funnel is "Serve, but the door is open." Same syntax, vastly different audience. Before flipping the switch, run through the "Is it safe to expose?" decision tool for any service. If it comes out yellow or red, either don't Funnel it, or wrap it behind an auth layer first.

Steps

Walk the safety decision tree ~5 min

Open the decision tool and walk through it for the service you're considering. For this project's example (GitHub webhook receiver) the tree should land on green.

Discipline rule: don't proceed unless you can write down (literally) why your service is safe to public-expose.

Enable Funnel in your tailnet policy ~3 min

Admin console → Access controls. Add (or merge) a nodeAttrs block:

{
  "nodeAttrs": [
    { "target": ["autogroup:member"], "attr": ["funnel"] }
  ]
}

Save. This permits any tailnet member to use Funnel.

Write the webhook receiver ~10 min

SSH into your home server. Create ~/webhook/server.py:

import hmac, hashlib, os, json
from http.server import HTTPServer, BaseHTTPRequestHandler

SECRET = os.environ['GH_SECRET'].encode()

class H(BaseHTTPRequestHandler):
    def do_POST(self):
        sig = self.headers.get('X-Hub-Signature-256', '')
        body = self.rfile.read(int(self.headers['Content-Length']))
        expected = 'sha256=' + hmac.new(SECRET, body, hashlib.sha256).hexdigest()
        if not hmac.compare_digest(sig, expected):
            self.send_response(401); self.end_headers(); return
        event = self.headers.get('X-GitHub-Event', '?')
        print(f"event: {event}", flush=True)
        print(json.loads(body).get('repository', {}).get('full_name', '-'), flush=True)
        self.send_response(200); self.end_headers(); self.wfile.write(b'ok')

HTTPServer(('127.0.0.1', 9000), H).serve_forever()

Run it:

export GH_SECRET="$(openssl rand -hex 32)"
echo $GH_SECRET   # save this — you'll paste into GitHub
python3 ~/webhook/server.py

Funnel the receiver ~2 min

In another SSH session:

sudo tailscale funnel --bg http://localhost:9000

Output: a public URL like https://home-server.tail-abc.ts.net/. This is reachable from anywhere on the internet, with HTTPS already set up.

Configure the webhook in GitHub ~3 min

In your GitHub repo: Settings → Webhooks → Add webhook.

  • Payload URL: your Funnel URL
  • Content type: application/json
  • Secret: the random hex string you generated
  • Which events: pick what you care about

Save. GitHub immediately sends a "ping" event. If your script prints event: ping, you're good.

Take it down when done ~1 min

sudo tailscale funnel --https=443 off

Or remove the funnel attr from nodeAttrs in policy to disable Funnel across the whole tailnet — the kill switch.

Verify

Variations

Caveats

Where this leads