-
-
Notifications
You must be signed in to change notification settings - Fork 523
X-Forwarded Headers not used #1612
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
Labels
invalid
This doesn't seem right
Comments
will be reviewed |
The problem, is your implementation. Replacing your Bean: @Bean
public FilterRegistrationBean<ForwardedHeaderFilter> forwardedHeaderFilter() {
ForwardedHeaderFilter filter = new ForwardedHeaderFilter();
FilterRegistrationBean<ForwardedHeaderFilter> registration = new FilterRegistrationBean<>(filter);
registration.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.ASYNC, DispatcherType.ERROR);
registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
registration.setUrlPatterns(List.of("/**"));
return registration;
} By the following, as described in the documentation: @Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
return new ForwardedHeaderFilter();
} Solves the problem. |
Hi @bnasslahsen, Thank you so much for taking time to look on the issue. I've made it worked by following suggestion from #331 |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
Getting "Failed to load remote configuration." when accessing swagger-ui behind api gateway.
Have gone through #215, #153 and https://springdoc.org/faq.html#how-can-i-deploy-springdoc-openapi-ui-behind-a-reverse-proxy
Have set server.forward-headers-strategy = framework.
The api gateway is host on port 8080, serving ServiceA at port 8081 when accessed via /api/servicea/.
A call to test service in ServiceA through api gateway shows that http headers are all set:
C:>curl http://localhost:8080/api/servicea/test
Request HTTP Headers:{user-agent=curl/7.79.1, accept=/, forwarded=proto=http;host="localhost:8080";for="127.0.0.1:50729", x-forwarded-for=127.0.0.1, x-forwarded-proto=http, x-forwarded-prefix=/api/servicea, x-forwarded-port=8080, x-forwarded-host=localhost:8080, host=localhost:8081, content-length=0}
While a call made directly to test service it is not having X-Forwarded headers:
C:>curl http://localhost:8081/test
Request HTTP Headers:{host=localhost:8081, user-agent=curl/7.79.1, accept=/}
To Reproduce
Steps to reproduce the behavior:
What version of spring-boot you are using?
2.6.6
What modules and versions of springdoc-openapi are you using?
springdoc-openapi-ui, version 1.6.7
Provide with a sample code (HelloController) or Test that reproduces the problem
minimal reproducible code: https://github.com/sonic-air-swimmer/SpringCloudGatewaySwagger
Expected behavior
Able to access swagger-ui when going through api gateway.
Screenshots

If applicable, add screenshots to help explain your problem.
The text was updated successfully, but these errors were encountered: