-
Notifications
You must be signed in to change notification settings - Fork 38.5k
ReactorServerHttpRequest does not reflect forwarded host and port when forwarding-header-strategy=native
or cloud platform detected
#28601
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
forwarding-header-strategy=native
or cloud platform is detected
Thanks for the sample. Indeed, we take the scheme from the Reactor Netty Lines 80 to 114 in d7824c7
It looks like up until 5cac619 before we were using the @violetagg what is your recommendation for how we should be getting the host and address? Is there a reason to look at the "Host" header, or should we always use /cc @bclozel |
forwarding-header-strategy=native
or cloud platform is detectedforwarding-header-strategy=native
or cloud platform detected
@rstoyanchev I think that
Recently we exposed all information: See https://projectreactor.io/docs/netty/release/api/reactor/netty/http/server/ConnectionInformation.html |
@violetagg, for the scheme, we use The Host header is "localhost:8080", and not the "mygateway:8181" from the forwarded headers. Is this expected? If not you can run the sample and have a closer look. If it is, then I'm wondering if we should just stop parsing the "Host" header ourselves, and use the API you suggested, |
Affects: Spring Webflux 5.3.20
Running our app in our kubernetes cluster (or simulating it via
spring.main.cloud-platform=kubernetes
) or usingserver.forward-headers-strategy=native
produces the wrong scheme when callingServerWebExchange.getRequest().getURI()
when forward headers are present.This seems to be because
ReactorServerHttpRequest
usesrequest.scheme()
(which netty fills fromX-Forwarded-Proto
if present), and combines it with theHost
header, where there's no clear correlation between those two headers.Effectively, the following cURL request:
... will return
ServerWebExchange.getRequest().getURI() = https://localhost:8080/print-uri
, even though the scheme used for the request was HTTP.Minimal Controller Example: https://github.com/mabako/spring-native-forwarding-headers-webflux/blob/master/src/main/java/com/example/demo/PrintUriController.java
The text was updated successfully, but these errors were encountered: