mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 02:09:47 +08:00
fix transparent host header #916
This commit is contained in:
parent
3fd3feeffe
commit
8d7136fc06
|
@ -69,6 +69,19 @@ func NewStaticUpstreams(c caddyfile.Dispenser) ([]Upstream, error) {
|
||||||
to = append(to, parsed...)
|
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() {
|
for c.NextBlock() {
|
||||||
switch c.Val() {
|
switch c.Val() {
|
||||||
case "upstream":
|
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 != "" {
|
if upstream.HealthCheck.Path != "" {
|
||||||
upstream.HealthCheck.Client = http.Client{
|
upstream.HealthCheck.Client = http.Client{
|
||||||
Timeout: upstream.HealthCheck.Timeout,
|
Timeout: upstream.HealthCheck.Timeout,
|
||||||
|
@ -287,7 +287,7 @@ func parseBlock(c *caddyfile.Dispenser, u *staticUpstream) error {
|
||||||
}
|
}
|
||||||
u.downstreamHeaders.Add(header, value)
|
u.downstreamHeaders.Add(header, value)
|
||||||
case "transparent":
|
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-Real-IP", "{remote}")
|
||||||
u.upstreamHeaders.Add("X-Forwarded-For", "{remote}")
|
u.upstreamHeaders.Add("X-Forwarded-For", "{remote}")
|
||||||
u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}")
|
u.upstreamHeaders.Add("X-Forwarded-Proto", "{scheme}")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user