我们有个项目使用spring boot开发, 使用nginx做反向代理,在nginx里边配置了https证书,但是在重定向的时候,老是重定向到http,解决方法如下:
1.在nginx中添加如下配置
proxy_set_header X-Forwarded-Proto $scheme;
比如
location /xxx/{
client_max_body_size 50m;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:7002/xxx/;
}
2.在application.properties添加如下配置
server.use-forward-headers=true
server.tomcat.protocol-header=X-Forwarded-Proto
完美解决。