我使用SpringDoc
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>1.6.9</version>
</dependency>
使用SpringBoot 2.7.0
SpringDoc配置为使用管理端口(8081),应用程序在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
应用程序运行在反向代理(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;
}
}
但是当我转到swagger页面时,我可以在主机名后面和生成的curl中看到应用程序端口,但是这个端口在代理后面不应该可见。
我错过了什么?
1条答案
按热度按时间yzuktlbb1#
我遇到了同样的问题,可以通过删除
一起