@marcel91200 / caddy Mirror · read-only / commits / c1e5c092
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 14, 05:15 UTC

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>

Francis Lavoie committed May 26, 2020 at 16:13 UTC c1e5c09294abdb01bb404aafced7c9092b202070
1 file changed +7
modules/caddyhttp/reverseproxy/caddyfile.go
+7
@@ -103,6 +103,13 @@ func (h *Handler) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
103 var network, scheme, host, port string
104
105 if strings.Contains(upstreamAddr, "://") {
106 + // we get a parsing error if a placeholder is specified
107 + // so we return a more user-friendly error message instead
108 + // to explain what to do instead
109 + if strings.Contains(upstreamAddr, "{") {
110 + return "", d.Err("due to parsing difficulties, placeholders are not allowed when an upstream address contains a scheme")
111 + }
112 +
113 toURL, err := url.Parse(upstreamAddr)
114 if err != nil {
115 return "", d.Errf("parsing upstream URL: %v", err)