-
Notifications
You must be signed in to change notification settings - Fork 471
Using spring-hateoas behind a HTTPS proxy #107
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
your proxy should set specific headers that contain the original uri (which includes https) like x-forwarded-proto. |
I solved my problem by adding a HttpServletRequestWrapper in a servlet filter when x-forwarded-* headers are present, and that solved my problem. But it could be more elegant and require less code if the ControllerLinkBuilder class could respect these headers if such a feature were enabled. |
The |
I can see now that support is there (X-Forwarded-Ssl). Not sure if it was there when I added this issue (pretty sure is was not). Anyways, I will gladly close this issue now :) |
The code for |
For those of us that are using Amazon AWS, and off-loading SSL at the AWS Load Balancer, we are limited to
Without this I cannot run any spring-haeoas in production. |
ControllerLinkBuilder now favors the value of the Forwarded and X-Forwarded-Proto header to build the scheme for the link created. For more information on the Forwarded header, see http://tools.ietf.org/html/rfc7239. Related issue: #107.
I'm wondering how you would forward a prefix of the URI. Considering @Laures mentioning "https://wherever/your/service/is", would it be possible to get the following scenario to work: The gateway is located on: The actual endpoint has a link to: And that link should be returned to the gateway as: In this scenario I can use "X-Forwarded-Proto" and "X-Forwarded-Host" (or its Forwarded equivalents), but how would I forward the prefix? |
Seems like "X-Forwarded-Prefix" did the trick for me, but I don't understand completely why. |
@lorethan See, https://jira.spring.io/browse/SPR-12500 why this works. |
With Apache in front of tomcat, you can resolve the problem by specifing the header _X-Forwarded-Proto_ as part of your virtual host configuration
|
I don't have control over the header. Our networking team has chosen a proprietary header because the "standard" header has unpredictable results. It would be useful if we could specify our own header. |
I just wrote a shim to transform the link based on the request header to resolve it for now. |
For those having this issue with Spring > 5.1: It handles the forward-headers properly, but you have to enable it by setting the property |
You can read it in detail => https://docs.spring.io/spring-hateoas/docs/1.0.0.RC2/reference/html/#server.link-builder.forwarded-headers |
Requiring my clients to provide the header is bad and error prone. To have to fake the forwarded header doesn't seem a too good idea either (obfuscates the fact that you just want to set the hostname for generated links and may have side effects that are non obvious) Why not provide a property or a way to set the hostname programmatically for the HATEOAS link-generation? |
What is the configuration of yours servers? Because this is textbook cloud configuration. Having an app behind a load balancer KNOW what the load balancer knows sort of de-inverts things. |
It's not a real loadbalancer, when you use Eureka or consul to make client side loadbalancing using service-IDs, then you don't have forwarded headers. |
Since we aren’t talking about an HTTP proxy, would you be willing to open a new ticket? |
Hi.
I am using the ControllerLinkBuilder to generate links for my responses, but I am not able to override the protocol in any way. The proxy (Hiawatha) uses https, but forwards to my tomcat server with http.
Is there anything I have missed that should make this possible, or is the some hook that could make this possible in any way?
The text was updated successfully, but these errors were encountered: