fabio icon indicating copy to clipboard operation
fabio copied to clipboard

Forwarded and X-Forwarded header not used consistently

Open hlang opened this issue 4 years ago • 1 comments

Forwarded headers and migration from X-Forwarded- are defined in: https://tools.ietf.org/html/rfc7239#section-5.2 Fabio currently (v1.5.12) sets both headers, Forwarded and X-Forwarded-Host.

The issue is, that host is only set in X-Forwarded-Host.

Current

"Forwarded":         []string{"for=1.2.3.4; proto=http"},
"X-Forwarded-Host":  []string{"5.6.7.8:1234"},

Expected

"Forwarded":         []string{"for=1.2.3.4; proto=http; host=5.6.7.8:1234"},
"X-Forwarded-Host":  []string{"5.6.7.8:1234"},

Background: Frameworks like spring only evaluate parameters from Forward, if this header is present. All other X-Forward headers are then ignored. So spring-framework does not use the X-Forwarded-Host for requests coming from fabio. Hostnames in spring generated URLs are wrong. See related spring-framework discussion: https://github.com/spring-projects/spring-framework/issues/23819

hlang avatar Oct 21 '19 11:10 hlang

@hlang Thank you for the report. This should be a pretty straightforward fix. I'll try and knock it out between meetings today.

aaronhurt avatar Oct 21 '19 13:10 aaronhurt