'ServletUriComponentsBuilder.fromCurrentContextPath() inside ElasticBeanstalk return http instead of https
I deployed a Spring Boot Application on EB using a docker container. It works well but in some parts of my code I've something like this:
ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromCurrentContextPath();
to get the current url of the application. In the local machine it works fine but on EB (using classing load balancer) - that uses https protocol - that line of code return http instead of https.
I've already added this configuration in my project:
@Bean
FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
FilterRegistrationBean<ForwardedHeaderFilter> bean = new FilterRegistrationBean<>();
bean.setFilter(new ForwardedHeaderFilter());
return bean;
}
Do you have any hint to follow to fix the problem?
Solution 1:[1]
I solved using this Spring Boot property:
server.forward-headers-strategy = framework
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Dharman |
