question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Reverse proxy context path aware support for manually provided files

See original GitHub issue

Is 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.url is set to /openapi.json I 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.url i expect it to handle being served behind a reverse proxy. (of course given that the reverse proxies sets the correct headers X-Forwarded-Prefix / similar.)
  • Expanding on it; When defining a local file/url in springdoc.swagger-ui.url it 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().

AbstractSwaggerWelcome.java

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:closed
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
bnasslahsencommented, Jan 21, 2022

@JSimo ,

Ideally, by the end of this week!

1reaction
bnasslahsencommented, Jan 20, 2022

@JSimo,

Please feel free to validate this enhancement using the latest SNAPSHOT.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found