Skip to content

Utilize X-Forwarded Headers #215

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

Closed
aaron-hooper opened this issue Dec 3, 2019 · 4 comments
Closed

Utilize X-Forwarded Headers #215

aaron-hooper opened this issue Dec 3, 2019 · 4 comments
Labels
question Further information is requested

Comments

@aaron-hooper
Copy link

Please support the X-Forwarded headers (x-forwarded-host, x-forwarded-prefix, x-forwarded-port, x-forwarded-proto) when they exist to allow the swagger docs to be properly served from behind a reverse proxy.

@springdoc
Copy link
Collaborator

Hi @aaron-hooper,

The procy headers are natively supported by spring-boot.
Please have a look at the answer of #153. This should work without any issue.

Please don't forget to give a feedback about which option resolved your issue.

@aaron-hooper
Copy link
Author

Setting server.forward-headers-strategy=framework does allow the redirect to resolve, but there is still an issue with the static content.

When accessing the app directly without going through a proxy localhost:8080/swagger-ui.html the static resources are resolved, ie localhost:8080/swagger-ui/swagger-ui-bundle.js.

However when accessing via the reverse proxy localhost:8081/app-context/swagger-ui.html the static resources are returning a 404 because the path is missing /swagger-ui/ ie localhost:8081/app-context/swagger-ui-bundle.js.

@springdoc
Copy link
Collaborator

Hi,

You need to make sure you reverse proxy is also well configured:
For example using apache 2:

RequestHeader set X-Forwarded-Prefix "/custom-path"

Did you try with the Bean configuration?

@Bean
ForwardedHeaderFilter forwardedHeaderFilter() {
   return new ForwardedHeaderFilter();
} 

@springdoc springdoc deleted a comment from aaron-hooper Feb 8, 2020
@bnasslahsen bnasslahsen added the question Further information is requested label Jan 26, 2022
@onacit
Copy link

onacit commented Mar 27, 2023

Is the /custom-path a fixed one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants