Skip to content

Commit

Permalink
reverseproxy: Improve error message when using scheme+placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
francislavoie committed May 23, 2020
1 parent 7a365af commit da7f1a6
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions modules/caddyhttp/reverseproxy/caddyfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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("for now, placeholders are not allowed when specifying a scheme; instead, omit the scheme and use the transport subdirective if you need tls support")
}

toURL, err := url.Parse(upstreamAddr)
if err != nil {
return "", d.Errf("parsing upstream URL: %v", err)
Expand Down

0 comments on commit da7f1a6

Please sign in to comment.