我们在代理后面运行服务,nginx以便:
http://service-post:8080/swagger-ui.html被路由到公共地址https://host.com/services/post/swagger-ui.html
或者从另一种方式定义:
当 nginx 收到 on 请求时https://host.com/services/post/swagger-ui.html,它会剥离/services/post/前缀并将请求传递给路径上的post服务。/swagger-ui.html
在设置任何东西(使用默认 SpringDoc 配置)之前,我可以正确地看到http://service-post:8080/swagger-ui.html.
要在 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返回404forservice-post:8080/*和https://host.com/services/post/*
似乎唯一可行的是https://host.com/services/post/swagger-ui/index.html,它显示了 petstore 文档。
我们没有使用 Spring Boot ,只使用5.3.1版本的 Spring MVC 。
那么如何设置以保持对原始路径(例如/api-docs)的处理,但在前缀路径()上执行查找/services/post/api-docs?