summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:18:42 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:18:42 -0700
commitcb25dd72abec854b359ca8194cb07b2571d950d4 (patch)
tree7a587fe21275e6c3f7c3695e4ff9b3fe631b4d45 /modules
parentd55fa68902519a4603565b15aea8ea31e454434c (diff)
reverse_proxy: Add port to upstream address if only implied in scheme
Diffstat (limited to 'modules')
-rw-r--r--modules/caddyhttp/reverseproxy/command.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/modules/caddyhttp/reverseproxy/command.go b/modules/caddyhttp/reverseproxy/command.go
index e48b3e8..0c67428 100644
--- a/modules/caddyhttp/reverseproxy/command.go
+++ b/modules/caddyhttp/reverseproxy/command.go
@@ -18,6 +18,7 @@ import (
"encoding/json"
"flag"
"fmt"
+ "net"
"net/http"
"net/url"
"strings"
@@ -80,6 +81,14 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
return caddy.ExitCodeFailedStartup, fmt.Errorf("parsing 'to' URL: %v", err)
}
+ if toURL.Port() == "" {
+ toPort := "80"
+ if toURL.Scheme == "https" {
+ toPort = "443"
+ }
+ toURL.Host = net.JoinHostPort(toURL.Host, toPort)
+ }
+
ht := HTTPTransport{}
if toURL.Scheme == "https" {
ht.TLS = new(TLSConfig)