最近遇到这样一个问题,客户端发起https请求,nginx收到请求后通过http转发给springboot应用程序,当应用程序重定向时就会出现问题,返回的url变成http了,如图 解决方法如下 1、反向代理配置X-Forwarded-Proto头 2、修改springboot配置文件,将use-forward-headers设置为trueproxy_pass http://127.0.0.1:9099/;
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-Proto $scheme;
server:
port: 9099
use-forward-headers: true