Skip to content

Instantly share code, notes, and snippets.

@b-
Created September 12, 2025 02:27
Show Gist options
  • Save b-/9b7ca834e318700c3d680ae1e02af876 to your computer and use it in GitHub Desktop.
Save b-/9b7ca834e318700c3d680ae1e02af876 to your computer and use it in GitHub Desktop.
tailscale serve inline example with redirect and health check
services:
whoami-ts:
image: tailscale/tailscale:latest
environment:
TS_HOSTNAME: "whoami"
TS_SERVE_CONFIG: /config/ts_serve.json
TS_AUTHKEY: ${TS_AUTHKEY}
TS_EXTRA_ARGS: "--advertise-tags=tag:docker"
TS_ENABLE_HEALTH_CHECK: true
TS_LOCAL_ADDR_PORT: 127.0.0.1:41234
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://127.0.0.1:41234/healthz"] # Check Tailscale has a Tailnet IP and is operational
interval: 1m # How often to perform the check
timeout: 10s # Time to wait for the check to succeed
retries: 3 # Number of retries before marking as unhealthy
start_period: 10s # Time to wait before starting health checks
restart: always
configs:
- source: whoami_serve
target: /config/ts_serve.json
- source: whoami_redirect
target: /config/redirect.html
whoami:
image: traefik/whoami
restart:
unless-stopped
network_mode: service:whoami-ts
configs:
whoami_serve:
content: |
{
"TCP": {
"443": {
"HTTPS": true
},
"80": {
"HTTP": true
}
},
"Web": {
"$${TS_CERT_DOMAIN}:443": {
"Handlers": {
"/": {
"Proxy": "http://127.0.0.1:80"
}
}
},
"$${TS_CERT_DOMAIN}:80": {
"Handlers": {
"/": {
"Path": "/config/redirect.html"
}
}
}
},
"AllowFunnel": {
"$${TS_CERT_DOMAIN}:443": false
}
}
whoami_redirect:
content: |
<!DOCTYPE html>
<html>
<head>
<title>Redirecting to Another page in HTML</title>
<!-- Redirecting to another page using meta tag -->
<meta http-equiv="refresh"
content="0; url =https://whoami.shark-perch.ts.net" />
</head>
<body>
<h3>
Redirecting to Another page in HTML
</h3>
<p><strong>Note:</strong> If your browser supports Refresh, you'll be
redirected to a secure page, in 0 seconds.
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment