mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-14 23:06:27 +03:00
reverse_proxy: Add port to upstream address if only implied in scheme
This commit is contained in:
parent
d55fa68902
commit
cb25dd72ab
1 changed files with 9 additions and 0 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -80,6 +81,14 @@ func cmdReverseProxy(fs caddycmd.Flags) (int, error) {
|
||||||
return caddy.ExitCodeFailedStartup, fmt.Errorf("parsing 'to' URL: %v", err)
|
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{}
|
ht := HTTPTransport{}
|
||||||
if toURL.Scheme == "https" {
|
if toURL.Scheme == "https" {
|
||||||
ht.TLS = new(TLSConfig)
|
ht.TLS = new(TLSConfig)
|
||||||
|
|
Loading…
Reference in a new issue