Commit cae98808 authored by Matt Holt's avatar Matt Holt

Merge pull request #483 from benschumacher/master

letsencrypt: Make plaintext redirect hosts honor the Bind settings
parents b6326d40 82b0c0b9
......@@ -42,8 +42,8 @@ func init() {
var directiveOrder = []directive{
// Essential directives that initialize vital configuration settings
{"root", setup.Root},
{"tls", setup.TLS}, // letsencrypt is set up just after tls
{"bind", setup.BindHost},
{"tls", setup.TLS}, // letsencrypt is set up just after tls
// Other directives that don't create HTTP handlers
{"startup", setup.Startup},
......
......@@ -446,6 +446,7 @@ func redirPlaintextHost(cfg server.Config) server.Config {
return server.Config{
Host: cfg.Host,
BindHost: cfg.BindHost,
Port: "http",
Middleware: map[string][]middleware.Middleware{
"/": []middleware.Middleware{redirMidware},
......
......@@ -39,6 +39,7 @@ func TestHostQualifies(t *testing.T) {
func TestRedirPlaintextHost(t *testing.T) {
cfg := redirPlaintextHost(server.Config{
Host: "example.com",
BindHost: "93.184.216.34",
Port: "http",
})
......@@ -46,6 +47,9 @@ func TestRedirPlaintextHost(t *testing.T) {
if actual, expected := cfg.Host, "example.com"; actual != expected {
t.Errorf("Expected redir config to have host %s but got %s", expected, actual)
}
if actual, expected := cfg.BindHost, "93.184.216.34"; actual != expected {
t.Errorf("Expected redir config to have bindhost %s but got %s", expected, actual)
}
if actual, expected := cfg.Port, "http"; actual != expected {
t.Errorf("Expected redir config to have port '%s' but got '%s'", expected, actual)
}
......
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