1

I use SpringDoc

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

with SpringBoot 2.7.0

SpringDoc configured to use management port(8081) and application runs on 8080.

server:
  forward-headers-strategy: FRAMEWORK
  error:
    include-message: always
    include-binding-errors: always
  port: 8080
management:
  server:
    port: 8081
  endpoints:
    enabled-by-default: false
    web:
      exposure:
        include: prometheus,beans,openapi,swaggerui
springdoc:
  use-management-port: true
  swagger-ui:
    display-request-duration: true
    disable-swagger-default-url: true
  show-actuator: true

Application runs behind reverse proxy(nginx)

upstream app_api {
        server localhost:8080;
}

upstream app_actuator {
        server localhost:8081;
}

server {
    listen 80;
    server_name templates;

    add_header Cache-Control no-cache;
    
    proxy_set_header Host      $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Host $host;
    proxy_set_header X-Forwarded-Port $server_port;
    proxy_set_header X-Forwarded-Proto $scheme;

    location / {
        proxy_pass http://app_api;
    }

    location /actuator {
        proxy_pass http://app_actuator;
    }

}

But when I go to the swagger page I can see the application port after the hostname and in the generated curl but this port should not be visible behind the proxy.

enter image description here

What did i miss?

Maxiko
  • 162
  • 2
  • 11

1 Answers1

0

I ran into the same problem and could resolve it by removing

server_name templates;

altogether.

mo_st
  • 149
  • 2
  • 12