Мой pom:
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
и файл конфигурации swagger
@Configuration
@EnableSwagger2
@EnableWebMvc
@Profile("stage")
public class SwaggerConfig {
@Bean
public Docket api() {
HashSet<String> protocols = new HashSet<>();
protocols.add("http");
protocols.add("https");
return new Docket(DocumentationType.SWAGGER_2)
.protocols(protocols)
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
.pathMapping("/");
}
@Bean
public WebMvcConfigurer webMvcConfigurer()
{
return new WebMvcConfigurer()
{
@Override
public void addResourceHandlers( ResourceHandlerRegistry registry )
{
registry.addResourceHandler( "swagger-ui.html" ).addResourceLocations( "classpath:/META-INF/resources/" );
registry.addResourceHandler( "/webjars/**" ).addResourceLocations( "classpath:/META-INF/resources/webjars/" );
}
};
}
}
Когда я получаю доступ к /swagger-ui.html на моей рабочей станции, все работает, но когда я запускаю этот проект на сценесреда, в которой у меня есть прокси-сервер nginx с настройками:
location ~ ^/(swagger|webjars|configuration|swagger-resources) {
proxy_pass https://backend;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
Моя сваггер-страница загружается, но получило предупреждение
Невозможно определить базовый URL. Это часто встречается при использовании динамической регистрации сервлета или когда API находится за шлюзом API. Базовый URL-адрес является корнем того, где обслуживаются все ресурсы чванства. Например, если API доступен в http://example.org/api/v2/api-docs, тогда базовый URL будет http://example.org/api/. Пожалуйста, введите местоположение вручную:
Когда я проверяю сетевые запросы, я могу найтивозвращенный сервер 404 Не найден для / swagger-resources / configuration / security
/ swagger-resources
/ swagger-resources / configuration / ui
любая подсказка?