我有个 web 应用,使用 Nginx 进行代理,Nginx 的配置如下(已简化):
http {
upstream appServerBackend {
server localhost:8081;
}
server {
listen 443 ssl http2;
server_name a.com;
location /appServer/ {
proxy_pass http://appServerBackend/;
}
}
}
web 应用使用 Swagger 产生文档,以下是 Swagger UI 展示的 Servers ,其值为http://appServerBackend:80,导致在 Swagger 执行请求时会请求http://appServerBackend:80,而不是期望的https://a.com/appServer。怎样操作才能实现“在 Swagger 执行请求时请求https://a.com/appServer”呢?

尝试解决
我尝试过修改 Nginx 的配置,在 proxy_pass 下面加上如下代码块。
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
Servers 变成了https://a.com:443,还不是我期望的https://a.com/appServer,我应该怎么操作才能让 Servers 变成https://a.com/appServer呢?