PCYOPCYO

山上有座庙

Nginx反向代理下Springboot应用redirect问题

环境:

nginx 1.20 (https)
springboot 2.3.5.RELEASE (http)

问题:

在springboot中的redirect,在重定向会走到http的端口上
redirect.png

解决办法

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

本原创文章未经允许不得转载 | 当前页面:PCYO » Nginx反向代理下Springboot应用redirect问题

评论