Commit 8d7136fc authored by Pedro Nasser's avatar Pedro Nasser

fix transparent host header #916

parent 3fd3feef
......@@ -69,6 +69,19 @@ func NewStaticUpstreams(c caddyfile.Dispenser) ([]Upstream, error) {
to = append(to, parsed...)
}
if len(to) == 0 {
return upstreams, c.ArgErr()
}
upstream.Hosts = make([]*UpstreamHost, len(to))
for i, host := range to {
uh, err := upstream.NewHost(host)
if err != nil {
return upstreams, err
}
upstream.Hosts[i] = uh
}
for c.NextBlock() {
switch c.Val() {
case "upstream":
......@@ -87,19 +100,6 @@ func NewStaticUpstreams(c caddyfile.Dispenser) ([]Upstream, error) {
}
}
if len(to) == 0 {
return upstreams, c.ArgErr()
}
upstream.Hosts = make([]*UpstreamHost, len(to))
for i, host := range to {
uh, err := upstream.NewHost(host)
if err != nil {
return upstreams, err
}
upstream.Hosts[i] = uh
}
if upstream.HealthCheck.Path != "" {
upstream.HealthCheck.Client = http.Client{
Timeout: upstream.HealthCheck.Timeout,
......@@ -287,7 +287,7 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
}
u.downstreamHeaders.Add(header, value)
case "transparent":
u.upstreamHeaders.Add("Host", "{host}")
u.upstreamHeaders.Add("Host", u.Hosts[0].Name)
u.upstreamHeaders.Add("X-Real-IP", "{remote}")
u.upstreamHeaders.Add("X-Forwarded-For", "{remote}")
u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment