From 3086fc82975f9f1b0f10052e6d2fdd2384986517 Mon Sep 17 00:00:00 2001 From: emersion Date: Sat, 9 Sep 2017 16:13:26 +0200 Subject: [PATCH] Add support for PORT env variable --- README.md | 1 + cmd/hydroxide/hydroxide.go | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f3fc89c..c8b25d5 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A third-party, open-source ProtonMail CardDAV bridge. Your credentials will be stored on disk encrypted with a 32-byte random password. When configuring your CardDAV client, you'll need this password. +You must setup an HTTPS reverse proxy to forward requests to `hydroxide`. ```shell go get github.com/emersion/hydroxide diff --git a/cmd/hydroxide/hydroxide.go b/cmd/hydroxide/hydroxide.go index 5fd9c47..8290cea 100644 --- a/cmd/hydroxide/hydroxide.go +++ b/cmd/hydroxide/hydroxide.go @@ -207,10 +207,15 @@ func main() { fmt.Println("Bridge password:", bridgePassword) case "": + port := os.Getenv("PORT") + if port == "" { + port = "8080" + } + sessions := make(map[string]*session) s := &http.Server{ - Addr: "127.0.0.1:8080", + Addr: "127.0.0.1:"+port, Handler: http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) { resp.Header().Set("WWW-Authenticate", "Basic")