summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--roseh.moe.go19
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))
+ }
}