Skip to content

Commit

Permalink
Allow binding to HTTP port (tailscale-dev#6)
Browse files Browse the repository at this point in the history
For use behind a reverse proxy. Only serves the same route and a funnel.

Reviewed-on: https://git.gmem.ca/arch/tclip/pulls/6
Co-authored-by: Gabriel Simmer <[email protected]>
Co-committed-by: Gabriel Simmer <[email protected]>
  • Loading branch information
gmemstr authored and Gabriel Simmer committed May 18, 2024
1 parent fdbbc6a commit 5a1cbd6
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/tclipd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ var (
useFunnel = flag.Bool("use-funnel", hasEnv("USE_FUNNEL"), "if set, expose individual pastes to the public internet with Funnel, USE_FUNNEL in the environment")
hidePasteUserInfo = flag.Bool("hide-funnel-users", hasEnv("HIDE_FUNNEL_USERS"), "if set, display the username and profile picture of the user who created the paste in funneled pastes")
databaseUrl = flag.String("database-url", envOr("DATABASE_URL", ""), "optional database url if you'd rather use Postgres instead of sqlite")
httpPort = flag.String("http-port", envOr("HTTP_PORT", ""), "optional http port to start an http server on, e.g for reverse proxies. will only serve funnel endpoints")

//go:embed schema.sql
sqlSchema string
Expand Down Expand Up @@ -742,6 +743,10 @@ func main() {

log.Printf("listening on http://%s", *hostname)
go func() { log.Fatal(http.Serve(ln, tailnetMux)) }()
if *httpPort != "" {
log.Printf("listening on :%s", *httpPort)
go func() { log.Fatal(http.ListenAndServe(":"+*httpPort, funnelMux)) }()
}

if *useFunnel {
log.Println("trying to listen on funnel")
Expand Down

0 comments on commit 5a1cbd6

Please sign in to comment.