【发布时间】:2021-03-13 10:20:13
【问题描述】:
我们在 nginx 代理后面运行服务,以便:
http://service-post:8080/swagger-ui.html 被路由到公共地址https://host.com/services/post/swagger-ui.html
或者换个说法:
当 nginx 收到https://host.com/services/post/swagger-ui.html 上的请求时,它会剥离/services/post/ 前缀并将请求传递给/swagger-ui.html 路径上的post 服务。
在设置任何东西(使用默认 SpringDoc 配置)之前,我可以正确地看到 http://service-post:8080/swagger-ui.html 上的 swagger 文档。
为了在 host.com 上设置公共地址的路径,我使用的是:
springdoc.api-docs.path: /services/post/api-docs
springdoc.swagger-ui.path: /services/post/swagger-ui.html
springdoc.swagger-ui.configUrl: /services/post/v3/api-docs/swagger-config
然而,这似乎完全阻止了它:
/swagger-ui.html、/api-docs 和 /v3/api-docs/swagger-config 均返回 404 service-post:8080/* 和 https://host.com/services/post/*
似乎唯一有效的是https://host.com/services/post/swagger-ui/index.html,它显示了宠物商店的文档。
我们没有使用 Spring Boot,只是版本 5.3.1 的 Spring MVC。
那么我该如何设置以保持对原始路径(例如/api-docs)的处理,但在前缀路径(/services/post/api-docs)上执行查找?
【问题讨论】:
-
你为什么使用 springdoc.swagger-ui.configUrl ?
-
当然我试过不使用它,但它没有帮助。
标签: swagger swagger-ui springdoc springdoc-openapi-ui