Allow binding to HTTP port (#6)
All checks were successful
Nix build / build-docker-arm (push) Successful in 1m19s
Nix build / build-docker (push) Successful in 1m25s

For use behind a reverse proxy. Only serves the same route and a funnel.

Reviewed-on: #6
Co-authored-by: Gabriel Simmer <g@gmem.ca>
Co-committed-by: Gabriel Simmer <g@gmem.ca>
This commit is contained in:
Gabriel Simmer 2024-05-18 20:13:09 +01:00 committed by Gabriel Simmer
parent fdbbc6a891
commit 5a1cbd6490
Signed by: Arch Forgejo
GPG key ID: E58BBEB3C95BA466

View file

@ -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") 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") 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") 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 //go:embed schema.sql
sqlSchema string sqlSchema string
@ -742,6 +743,10 @@ func main() {
log.Printf("listening on http://%s", *hostname) log.Printf("listening on http://%s", *hostname)
go func() { log.Fatal(http.Serve(ln, tailnetMux)) }() 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 { if *useFunnel {
log.Println("trying to listen on funnel") log.Println("trying to listen on funnel")