Browse Source
reverse_proxy: Add port to upstream address if only implied in scheme
master
Matthew Holt
6 years ago
No known key found for this signature in database
GPG Key ID: 2A349DD577D586A5
1 changed files with
9 additions and
0 deletions
-
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) |
|
|
|