diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-10 17:41:38 -0800 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-11-10 17:41:38 -0800 |
| commit | f6a33d126e101ac5d691ac747634825cd8c5aa6f (patch) | |
| tree | 039301837b6cd3d60a8a86ada6d9916b44122ee8 | |
| parent | 1bf1b472382d966d27a5e5e926ed5de7979847a0 (diff) | |
| download | roseh.moe-f6a33d126e101ac5d691ac747634825cd8c5aa6f.tar.zst | |
Add back jellyfin proxy
We don't need no stupid nginx
| -rw-r--r-- | roseh.moe.go | 19 |
1 files changed, 18 insertions, 1 deletions
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)) + } } |
