Skip to content
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

Wrong host port when only X-Forwarded-Proto is present #2773

Merged
merged 5 commits into from
Apr 27, 2023

Conversation

pderop
Copy link
Contributor

@pderop pderop commented Apr 14, 2023

Motivation:
When resolving forwarded headers (X-Forwarded/Forwarded), the following scenario seems to happen in cloud foundry:

  • you send an https request to a cloud foundry application, for example an actuator request: https://cloudfoundryapplication/actuator
  • the front-end proxy forwards the request to a springboot application on non secure http 8080
  • The request contains a Host header without any port, as well as a X-Forwarded-Proto: https header
  • in this case, the DefaultHttpForwardedHeaderHandler class will wrongly resolve the host port as 80 instead of 443, because the request is received on a non-secure connection.
  • And the json response then contains an unexpected 80 port appended in the actuator urls:
{"_links":{"self":{"href":"https://cloudfoundryapplication:80/actuator","templated":false},"health-path":{"href":"https://cloudfoundryapplication:80/actuator/health/{*path}","templated":true},"health": ...

Have also applied the similar patch for Forwarded headers (like Forwarded: proto=https).
Fixes #2771

…dedHeaderHandler. Having only Proto header should only affect HOST,X-Forwarded-Host,Forwarded host default port.
…ultHttpForwardedHeaderHandler (will create a new PR for this).
@pderop
Copy link
Contributor Author

pderop commented Apr 26, 2023

in previous commit, drastically simplified the logic of the patch, based on Violeta's suggestions given privately (thanks !)

@pderop pderop merged commit 8eefda0 into reactor:1.0.x Apr 27, 2023
@pderop
Copy link
Contributor Author

pderop commented Apr 27, 2023

@violetagg , thanks for the review.

@pderop pderop deleted the 1.0.x-issue-2771 branch April 27, 2023 09:20
@violetagg violetagg changed the title Wrong host port 80 when only X-Forwarded-Proto: https is present Wrong host port when only X-Forwarded-Proto is present Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/bug A general bug
Projects
None yet
2 participants