1

I am using this OpenAPI 3 implementation in Spring Boot web project.

<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-ui</artifactId>
    <version>1.5.2</version>
</dependency>

My configuration for OpenAPI:

@Configuration
public class SpringFoxConfig {

    @Value("${openapi.server.baseUrl}")
    private String baseUrl;

    @Bean
    public OpenAPI customOpenAPI() {

        Server server = new Server();
        server.setUrl(baseUrl);

        List<Server> servers = new ArrayList<>();
        servers.add(server);

        return new OpenAPI()
            .components(new Components())
            .servers(servers)
            .info(new Info().title("Service REST API").description(
                "Generic Service REST API"));
    }
}

The value of the baseUrl is: https://apps.server.com/test/myservice

This service is running on a docker-swarm and is exposed via Nginx and Kong API gateway.

Web browser -> Nginx -> Kong -> Service

I am trying not to touch the Nginx server as much as possible and having created a service (protocol: http, port: 8080, host: service-name-in-kong) and route (paths: /myservice/ and /myservice) using Konga GUI tool.

When trying to access the swagger-ui.html at https://apps.server.com/test/myservice/swagger-ui.html -> it gets redirected to http://service-name-in-kong:8080/swagger-ui/index.html?configUrl=/v3/api-docs/swagger-config#/

Now i am confused as to why this happens?

Eugene
  • 1,013
  • 1
  • 22
  • 43
  • Is a nginx in your chain is the one form Kong or an extra one ? When you talk about a redirect is it a 301 redirect or the upstream reached by kong ? Have you tried to add `kong-debug: 1` http header to get more details ? – Ôrel May 20 '21 at 12:36
  • The nginx is an extra one. Hm i may have gotten the redirect wrong. It is actually 302 and the new URL becomes the http://service-name-in-kong instead of the https://apps.server.com/test/myservice. – Eugene May 20 '21 at 13:42
  • I think removing the Nginx can be a good idea to simplify, with the http header you will have details about the routing to understand which component is doing what – Ôrel May 20 '21 at 15:53

0 Answers0