Commit 7796ff0f authored by Matthew Holt's avatar Matthew Holt

core: Disable TLS for http sites (again)

Fixes bug introduced in 0ac8bf58 - Also note that setup functions no longer have access to server port. Will need to fix later.
parent afd6b7ea
...@@ -57,6 +57,11 @@ func Load(filename string, input io.Reader) (Group, error) { ...@@ -57,6 +57,11 @@ func Load(filename string, input io.Reader) (Group, error) {
if config.Port == "" { if config.Port == "" {
config.Port = 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 { if i == 0 {
sharedConfig.Startup = []func() error{} sharedConfig.Startup = []func() error{}
sharedConfig.Shutdown = []func() error{} sharedConfig.Shutdown = []func() error{}
......
...@@ -31,7 +31,7 @@ func FastCGI(c *Controller) (middleware.Middleware, error) { ...@@ -31,7 +31,7 @@ func FastCGI(c *Controller) (middleware.Middleware, error) {
SoftwareName: c.AppName, SoftwareName: c.AppName,
SoftwareVersion: c.AppVersion, SoftwareVersion: c.AppVersion,
ServerName: c.Host, ServerName: c.Host,
ServerPort: c.Port, ServerPort: c.Port, // BUG: This is not known until the server blocks are split up...
} }
}, nil }, nil
} }
......
...@@ -2,7 +2,6 @@ package setup ...@@ -2,7 +2,6 @@ package setup
import ( import (
"crypto/tls" "crypto/tls"
"log"
"strings" "strings"
"github.com/mholt/caddy/middleware" "github.com/mholt/caddy/middleware"
...@@ -10,11 +9,6 @@ import ( ...@@ -10,11 +9,6 @@ import (
func TLS(c *Controller) (middleware.Middleware, error) { func TLS(c *Controller) (middleware.Middleware, error) {
c.TLS.Enabled = true 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() { for c.Next() {
if !c.NextArg() { if !c.NextArg() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment