summaryrefslogtreecommitdiff
path: root/modules/caddyhttp/reverseproxy/caddyfile.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2020-04-07 11:41:49 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2020-04-07 11:41:49 -0600
commit61679b74f5975e6a5f1eeab4e209148aee9bcd5a (patch)
treee9dff911403b41f79f775c552f72a25f26a504db /modules/caddyhttp/reverseproxy/caddyfile.go
parent8b2dbc52ec6bc0359b4b8c47a3f9835e9460649e (diff)
parent2c1b66315620fda3311f9bdffd0867de1c71dc9e (diff)
Merge branch 'remove-ntlm'
Diffstat (limited to 'modules/caddyhttp/reverseproxy/caddyfile.go')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go26
1 files changed, 10 insertions, 16 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index cefb5b6..9636936 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -551,26 +551,20 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
// verify transport configuration, and finally encode it
if transport != nil {
- // TODO: these two cases are identical, but I don't know how to reuse the code
- switch ht := transport.(type) {
- case *HTTPTransport:
- if commonScheme == "https" && ht.TLS == nil {
- ht.TLS = new(TLSConfig)
- }
- if ht.TLS != nil && commonScheme == "http" {
- return d.Errf("upstream address scheme is HTTP but transport is configured for HTTP+TLS (HTTPS)")
- }
-
- case *NTLMTransport:
- if commonScheme == "https" && ht.TLS == nil {
- ht.TLS = new(TLSConfig)
+ if te, ok := transport.(TLSTransport); ok {
+ if commonScheme == "https" && !te.TLSEnabled() {
+ err := te.EnableTLS(new(TLSConfig))
+ if err != nil {
+ return err
+ }
}
- if ht.TLS != nil && commonScheme == "http" {
+ if commonScheme == "http" && te.TLSEnabled() {
return d.Errf("upstream address scheme is HTTP but transport is configured for HTTP+TLS (HTTPS)")
}
+ } else if commonScheme == "https" {
+ return d.Errf("upstreams are configured for HTTPS but transport module does not support TLS: %T", transport)
}
-
- if !reflect.DeepEqual(transport, new(HTTPTransport)) {
+ if !reflect.DeepEqual(transport, reflect.New(reflect.TypeOf(transport).Elem()).Interface()) {
h.TransportRaw = caddyconfig.JSONModuleObject(transport, "protocol", transportModuleName, nil)
}
}