|
|
|
|
@ -1,20 +1,40 @@
|
|
|
|
|
// Copyright (c) Tailscale Inc & AUTHORS
|
|
|
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
|
|
|
|
|
|
// The tsnet-services example demonstrates how to use tsnet with Services.
|
|
|
|
|
// TODO:
|
|
|
|
|
// - explain that a Service must be defined for the tailent and link to KB on
|
|
|
|
|
// defining a Service
|
|
|
|
|
// - recommend using an auth key with associated tags
|
|
|
|
|
// - recommend an auto-approval rule for service tags
|
|
|
|
|
// The tsnet-services example demonstrates how to use tsnet with Services
|
|
|
|
|
// which listen on multiple ports.
|
|
|
|
|
//
|
|
|
|
|
// TODO: can we provide example ACL which only allows certain user groups to hit
|
|
|
|
|
// the pprof port?
|
|
|
|
|
// To run this example yourself:
|
|
|
|
|
//
|
|
|
|
|
// To use it, generate an auth key from the Tailscale admin panel and
|
|
|
|
|
// run the demo with the key:
|
|
|
|
|
// 1. Define an ACL tag, an auto-approval rule, and traffic permits by adding
|
|
|
|
|
// the following to your tailnet's ACL policy file:
|
|
|
|
|
// TODO: convince gofmt to chill
|
|
|
|
|
// "tagOwners": {
|
|
|
|
|
// "tag:tsnet-demo-host": ["autogroup:member"],
|
|
|
|
|
// },
|
|
|
|
|
// "autoApprovers": {
|
|
|
|
|
// "services": {
|
|
|
|
|
// "svc:tsnet-demo": ["tag:tsnet-demo-host"],
|
|
|
|
|
// },
|
|
|
|
|
// },
|
|
|
|
|
// // Allow anybody in the tailnet to reach the demo Service.
|
|
|
|
|
// "grants": [
|
|
|
|
|
// "src": ["*"],
|
|
|
|
|
// "dst": ["tag:tsnet-demo-host"],
|
|
|
|
|
// "ip": ["*"],
|
|
|
|
|
// ],
|
|
|
|
|
//
|
|
|
|
|
// TS_AUTHKEY=<yourkey> go run tsnet-services.go -service <service-name>
|
|
|
|
|
// 2. Generate an auth key using the Tailscale admin panel. When doing so, add
|
|
|
|
|
// the tsnet-demo-host tag to your key.
|
|
|
|
|
// https://tailscale.com/kb/1085/auth-keys#generate-an-auth-key
|
|
|
|
|
//
|
|
|
|
|
// 2. Define a Service. For the purposes of this demo, it must be defined to
|
|
|
|
|
// listen on TCP ports 443 and 6060. Note that you only need to follow Step
|
|
|
|
|
// 1 in the following document.
|
|
|
|
|
// https://tailscale.com/kb/1552/tailscale-services#step-1-define-a-tailscale-service
|
|
|
|
|
//
|
|
|
|
|
// 3. Run the demo on the command line:
|
|
|
|
|
// TS_AUTHKEY=<yourkey> go run tsnet-services.go -service <service-name>
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|