Repository navigation
Closed
Description
Hello,
Is it expected that this commit 290523f changed the behavior of requet.host ? The new behavior is not documented in the commit message nor in the project changelog.
Here is an example repo where you can reproduce the issue: https://github.com/ylecuyer/bugged-rack-x-forwarded-host
Basically now it always returns host2 whereas before it was hostN (last host)
Before
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" -H "X-Forwarded-Host: host3" -H "X-Forwarded-Host: host4" http://localhost:9292
host4
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" -H "X-Forwarded-Host: host3" http://localhost:9292
host3
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" http://localhost:9292
host2
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" http://localhost:9292
host1
Now:
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" -H "X-Forwarded-Host: host3" -H "X-Forwarded-Host: host4" http://localhost:9292
host1
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" -H "X-Forwarded-Host: host3" http://localhost:9292
host1
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" -H "X-Forwarded-Host: host2" http://localhost:9292
host1
ylecuyer@lenovo:~$ curl -X GET -H "X-Forwarded-Host: host1" http://localhost:9292
host1
Metadata
Metadata
Assignees
Labels
No labels
Activity
ylecuyer commentedon Mar 14, 2022
Also I did the following patch:
And no test failed so this part isn't covered
We could add the following spec:
and everything would be as before
Allow configuring priorities for Forwarded and X-Forwarded-*
ioquatix commentedon Apr 4, 2022
@matthewd do you mind checking the example requests and confirming the behaviour looks correct/secure? Thanks :)
Allow configuring priorities for Forwarded and X-Forwarded-*
ioquatix commentedon Apr 5, 2022
Thanks @jeremyevans !