I have Spring Data Rest with Hateoas as my backed. It is behind a proxy.
Backend url: backend.com
Proxy url: proxy.com
When I query proxy url, e.g. http://proxy.com/items/1
, I get a response with href
links with domain backend.com
. I need the domain to be proxy.com
.
As of Spring-Boot 2.1 / Spring 5.1, Spring shifts the responsibility of handling X-Forwarded-* from Spring HATEOAS to Spring MVC.
https://jira.spring.io/browse/SPR-16668
You now require the registration of a filter bean.
Minimal implementation:
@Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter()
{
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter());
return bean;
}