环境:
nginx 1.20 (https)
springboot 2.3.5.RELEASE (http)
问题:
在springboot中的redirect,在重定向会走到http的端口上
解决办法
nginx配置:
server {
listen 80;
listen 443 ssl;
server_name test.com;
ssl_certificate my.crt;
ssl_certificate_key my.key;
location / {
proxy_pass http://test.com:8080;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
springboot application.yml配置:
server:
port: 8080
tomcat:
remote:
port-header: X-Forwarded-Port
remoteip:
protocol-header: x-forwarded-proto
remote-ip-header: x-forwarded-for
forward-headers-strategy: native