From 7796ff0f690b96f49d310cbd1817dedcf1a40fad Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Wed, 5 Aug 2015 11:33:51 -0600 Subject: [PATCH] core: Disable TLS for http sites (again) Fixes bug introduced in 0ac8bf5 - Also note that setup functions no longer have access to server port. Will need to fix later. --- config/config.go | 5 +++++ config/setup/fastcgi.go | 2 +- config/setup/tls.go | 6 ------ 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/config/config.go b/config/config.go index 3037a2678..82a29585f 100644 --- a/config/config.go +++ b/config/config.go @@ -57,6 +57,11 @@ func Load(filename string, input io.Reader) (Group, error) { if config.Port == "" { config.Port = Port } + if config.Port == "http" { + config.TLS.Enabled = false + log.Printf("Warning: TLS disabled for %s://%s. To force TLS over the plaintext HTTP port, "+ + "specify port 80 explicitly (https://%s:80).", config.Port, config.Host, config.Host) + } if i == 0 { sharedConfig.Startup = []func() error{} sharedConfig.Shutdown = []func() error{} diff --git a/config/setup/fastcgi.go b/config/setup/fastcgi.go index a2a7e8794..ab21ef1f2 100644 --- a/config/setup/fastcgi.go +++ b/config/setup/fastcgi.go @@ -31,7 +31,7 @@ func FastCGI(c *Controller) (middleware.Middleware, error) { SoftwareName: c.AppName, SoftwareVersion: c.AppVersion, ServerName: c.Host, - ServerPort: c.Port, + ServerPort: c.Port, // BUG: This is not known until the server blocks are split up... } }, nil } diff --git a/config/setup/tls.go b/config/setup/tls.go index 36ecac05e..431409f4a 100644 --- a/config/setup/tls.go +++ b/config/setup/tls.go @@ -2,7 +2,6 @@ package setup import ( "crypto/tls" - "log" "strings" "github.com/mholt/caddy/middleware" @@ -10,11 +9,6 @@ import ( func TLS(c *Controller) (middleware.Middleware, error) { c.TLS.Enabled = true - if c.Port == "http" { - c.TLS.Enabled = false - log.Printf("Warning: TLS disabled for %s://%s. To force TLS over the plaintext HTTP port, "+ - "specify port 80 explicitly (https://%s:80).", c.Port, c.Host, c.Host) - } for c.Next() { if !c.NextArg() {