Spring Grails runnable jar 中的安全性重定向到 HTTP

Spring Security in Grails runnable jar redirects to HTTP

我正在使用 grails 3 可运行 jar 和 spring 反向代理背后的安全性处理 https 到 http 流量(和 https 到 http 重定向),将其转发到 http://my-host:8080

对于我的所有 /login/** 调用,grails 将“302 重定向”发送到 http

例如 /login/authenticate XHR 使用 header 重定向 Location: http://my-big-ip/login/ajaxSuccess,等等

它没有使用我在 application.yml 到 https://my-big-ip

中设置的 serverURL 参数

我的 jar 正在使用嵌入式 tomcat,因为我的 build.gradle

中有这个
compile "org.springframework.boot:spring-boot-starter-tomcat"

我得到的关于这个重定向的日志

2019-03-27 15:56:34,415 DEBUG http-nio-8088-exec-5  org.springframework.security.web.savedrequest.HttpSessionRequestCache - Removing DefaultSavedRequest from session if present  
2019-03-27 15:56:34,415 DEBUG http-nio-8088-exec-5  grails.plugin.springsecurity.web.authentication.AjaxAwareAuthenticationSuccessHandler - Redirecting to Ajax Success Url: /login/ajaxSuccess  
2019-03-27 15:56:34,415 DEBUG http-nio-8088-exec-5  grails.plugin.springsecurity.web.GrailsRedirectStrategy - Redirecting to '/login/ajaxSuccess'

我相信您需要将此添加到您的 application/runtime.(groovy|yml):

server."use-forward-headers" = true

此处 https://docs.spring.io/spring-boot/docs/current/reference/html/howto-embedded-web-servers.html 有大量文档(关于此内容和其他内容),如果您对其他详细信息感兴趣,可能会有所帮助。