From f6a33d126e101ac5d691ac747634825cd8c5aa6f Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Mon, 10 Nov 2025 17:41:38 -0800 Subject: Add back jellyfin proxy We don't need no stupid nginx --- roseh.moe.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/roseh.moe.go b/roseh.moe.go index 3cab2c4..97487de 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -16,6 +16,8 @@ import ( "log" "mime/multipart" "net/http" + "net/http/httputil" + "net/url" "os" "strings" "sync" @@ -32,6 +34,7 @@ var ( selfURL = flag.String("self-url", "http://localhost:42069", "base URL of the server") secretsFile = flag.String("secrets", "secrets.ccl", "secrets file") configFile = flag.String("config", "config.ccl", "configuration file (ccl format https://pkg.go.dev/roseh.moe/pkg/ccl)") + https = flag.Bool("https", false, "use https") serverStartTime = time.Now() ) @@ -566,8 +569,22 @@ func main() { http.HandleFunc("GET /favicon.ico", favicon) http.HandleFunc("GET /{$}", index) http.HandleFunc("GET /", notFound) + jellyfinURL, err := url.Parse("http://localhost:8192") + if err != nil { + log.Fatal(err) + } + http.Handle("cinema.roseh.moe/", &httputil.ReverseProxy{ + Rewrite: func(r *httputil.ProxyRequest) { + r.SetURL(jellyfinURL) + r.SetXForwarded() + }, + }) addr := fmt.Sprintf(":%d", *port) log.Printf("Listening on %q", addr) - log.Fatal(http.ListenAndServe(addr, nil)) + if *https { + log.Fatal(http.ListenAndServeTLS(addr, "/var/lib/acme/roseh.moe/cert.pem", "/var/lib/acme/roseh.moe/key.pem", nil)) + } else { + log.Fatal(http.ListenAndServe(addr, nil)) + } } -- cgit v1.3.1