From 82b0c0b9eb7c4ae0ef50ab8cf64a340e3d725de5 Mon Sep 17 00:00:00 2001 From: Ben Schumacher Date: Sun, 3 Jan 2016 00:37:57 -0700 Subject: [PATCH] Make Let's Encrypt module honor the Bind settings --- caddy/directives.go | 2 +- caddy/letsencrypt/letsencrypt.go | 5 +++-- caddy/letsencrypt/letsencrypt_test.go | 8 ++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/caddy/directives.go b/caddy/directives.go index 54298502..39b54b7d 100644 --- a/caddy/directives.go +++ b/caddy/directives.go @@ -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}, diff --git a/caddy/letsencrypt/letsencrypt.go b/caddy/letsencrypt/letsencrypt.go index feeac297..63eeaf7f 100644 --- a/caddy/letsencrypt/letsencrypt.go +++ b/caddy/letsencrypt/letsencrypt.go @@ -445,8 +445,9 @@ func redirPlaintextHost(cfg server.Config) server.Config { } return server.Config{ - Host: cfg.Host, - Port: "http", + Host: cfg.Host, + BindHost: cfg.BindHost, + Port: "http", Middleware: map[string][]middleware.Middleware{ "/": []middleware.Middleware{redirMidware}, }, diff --git a/caddy/letsencrypt/letsencrypt_test.go b/caddy/letsencrypt/letsencrypt_test.go index dd243c0b..0547b929 100644 --- a/caddy/letsencrypt/letsencrypt_test.go +++ b/caddy/letsencrypt/letsencrypt_test.go @@ -38,14 +38,18 @@ func TestHostQualifies(t *testing.T) { func TestRedirPlaintextHost(t *testing.T) { cfg := redirPlaintextHost(server.Config{ - Host: "example.com", - Port: "http", + Host: "example.com", + BindHost: "93.184.216.34", + Port: "http", }) // Check host and port 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) }