From afb15f2bab720f8c520ec09f83adab90f9d7663c Mon Sep 17 00:00:00 2001 From: Gabriel Simmer Date: Sat, 18 May 2024 20:03:34 +0100 Subject: [PATCH] Allow binding to HTTP port For use behind a reverse proxy. Only serves the same route and a funnel. --- cmd/tclipd/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/tclipd/main.go b/cmd/tclipd/main.go index afe1975..e031689 100644 --- a/cmd/tclipd/main.go +++ b/cmd/tclipd/main.go @@ -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 @@ -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")