summaryrefslogtreecommitdiff
path: root/modules/caddyhttp
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2020-05-26 16:13:15 -0400
committerGitHub <noreply@github.com>2020-05-26 14:13:15 -0600
commitc1e5c09294abdb01bb404aafced7c9092b202070 (patch)
tree8e7001fa18ed70bd064b0b2ecdf4a7a2e3466655 /modules/caddyhttp
parentffc125d6f5606ab4370ea244e66dfb05cd78eb28 (diff)
reverseproxy: Improve error message when using scheme+placeholder (#3393)
* reverseproxy: Improve error message when using scheme+placeholder * reverseproxy: Simplify error message Co-authored-by: Matt Holt <mholt@users.noreply.github.com> Co-authored-by: Matt Holt <mholt@users.noreply.github.com>
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r--modules/caddyhttp/reverseproxy/caddyfile.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/caddyfile.go b/modules/caddyhttp/reverseproxy/caddyfile.go
index 491b067..47896a7 100644
--- a/modules/caddyhttp/reverseproxy/caddyfile.go
+++ b/modules/caddyhttp/reverseproxy/caddyfile.go
@@ -103,6 +103,13 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
var network, scheme, host, port string
if strings.Contains(upstreamAddr, "://") {
+ // we get a parsing error if a placeholder is specified
+ // so we return a more user-friendly error message instead
+ // to explain what to do instead
+ if strings.Contains(upstreamAddr, "{") {
+ return "", d.Err("due to parsing difficulties, placeholders are not allowed when an upstream address contains a scheme")
+ }
+
toURL, err := url.Parse(upstreamAddr)
if err != nil {
return "", d.Errf("parsing upstream URL: %v", err)