From 68793ffe133f0ad67b28d221fe22d05fb4f0c772 Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Mon, 4 May 2015 22:26:28 -0700 Subject: [PATCH 1/2] Disable tls if the port is http --- config/setup/tls.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/setup/tls.go b/config/setup/tls.go index ea267534..93e9324d 100644 --- a/config/setup/tls.go +++ b/config/setup/tls.go @@ -3,7 +3,7 @@ package setup import "github.com/mholt/caddy/middleware" func TLS(c *Controller) (middleware.Middleware, error) { - c.TLS.Enabled = true + c.TLS.Enabled = c.Port != "http" for c.Next() { if !c.NextArg() { From accb3e616d4ae783e53a2c7015dc48e08f5be010 Mon Sep 17 00:00:00 2001 From: Nimi Wariboko Jr Date: Tue, 5 May 2015 12:30:24 -0700 Subject: [PATCH 2/2] Add warning message when tls is disabled when its used on http --- config/setup/tls.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/config/setup/tls.go b/config/setup/tls.go index 93e9324d..f084e6c6 100644 --- a/config/setup/tls.go +++ b/config/setup/tls.go @@ -1,9 +1,19 @@ package setup -import "github.com/mholt/caddy/middleware" +import ( + "github.com/mholt/caddy/middleware" + "log" +) func TLS(c *Controller) (middleware.Middleware, error) { - c.TLS.Enabled = c.Port != "http" + c.TLS.Enabled = true + if c.Port == "http" { + c.TLS.Enabled = false + log.Printf("Warning: TLS was disabled on host http://%s."+ + " Make sure you are specifying https://%s in your config (if you haven't already)."+ + " If you meant to serve tls on port 80,"+ + " specify port 80 in your config (http://%s:80).", c.Host, c.Host, c.Host) + } for c.Next() { if !c.NextArg() {