Reverse proxy context path aware support for manually provided files
See original GitHub issueIs your feature request related to a problem? Please describe.
- Trying to configure springdoc to serve a custom openapi.json file behind a reverse proxy. Where the default page should have that file be selected in a context path aware manner.
- When the property
springdoc.swagger-ui.urlis set to/openapi.jsonI expect the path to be context path aware. Similar to how the normal api-docs is handled.
Describe the solution you’d like
- When defining a local url / file in the
springdoc.swagger-ui.urli expect it to handle being served behind a reverse proxy. (of course given that the reverse proxies sets the correct headersX-Forwarded-Prefix/ similar.) - Expanding on it; When defining a local file/url in
springdoc.swagger-ui.urlit is expected that such a url is handled in a context path aware manner.
Describe alternatives you’ve considered I’ve considered hacks around it, such as defining the static file with the prefix of the reverse proxy in it. But that means any local testing will not work.
Looking into the code I have considered changing the following method somehow as that is where the url is being modified. And from what I can see it might be possible to do something around String swaggerUiUrl = swaggerUiConfig.getUrl(); line to handle it in a similar way as done in buildApiDocUrl().
protected void buildConfigUrl(UriComponentsBuilder uriComponentsBuilder) {
if (StringUtils.isEmpty(swaggerUiConfig.getConfigUrl())) {
apiDocsUrl = buildApiDocUrl();
swaggerConfigUrl = buildSwaggerConfigUrl();
swaggerUiConfigParameters.setConfigUrl(swaggerConfigUrl);
if (CollectionUtils.isEmpty(swaggerUiConfigParameters.getUrls())) {
String swaggerUiUrl = swaggerUiConfig.getUrl();
if (StringUtils.isEmpty(swaggerUiUrl))
swaggerUiConfigParameters.setUrl(apiDocsUrl);
else
swaggerUiConfigParameters.setUrl(swaggerUiUrl);
}
else
swaggerUiConfigParameters.addUrl(apiDocsUrl);
}
calculateOauth2RedirectUrl(uriComponentsBuilder);
}
Additional context Also would be fine with any other possibilities such as a flag to make ``springdoc.swagger-ui.url` context aware or any suggestions!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Configure ASP.NET Core to work with proxy servers and load ...
Learn about configuration for apps hosted behind proxy servers and load balancers, which often obscure important request information.
Read more >mod_proxy - Apache HTTP Server Version 2.4
mod_proxy and related modules implement a proxy/gateway for Apache HTTP Server, supporting a number of popular protocols as well as several different load ......
Read more >Building a Reverse Proxy in .NET Core - Auth0
Learn how to use .NET Core to implement a reverse proxy to overcome specific needs that you could hardly solve with an out-of-the-box...
Read more >How do I configure Matomo when the server is installed ...
If Matomo was unable to detect your proxy configuration, you may add these lines manually in your Matomo config.ini.php file (remove the leading...
Read more >Module ngx_http_proxy_module - Nginx.org
Module ngx_http_proxy_module. Example Configuration Directives proxy_bind proxy_buffer_size proxy_buffering proxy_buffers proxy_busy_buffers_size proxy_cache
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@JSimo ,
Ideally, by the end of this week!
@JSimo,
Please feel free to validate this enhancement using the latest SNAPSHOT.