我在 Proxy 后面用 SpringBoot 构建了一个授权服务(目前是 Apache,稍后将是 Nginx)。 该服务处理身份验证(委托(delegate)给 google、facebook 等)并返回 JWT。
问题:使用 tomcat 作为容器,身份验证成功后重定向到 http://example.com .有了 undertow 一切都很好 ( https://example.com )
我在Apache中设置
ProxyPass /auth http://localhost:8080/auth
ProxyPassReverse /auth http://localhost:8080/auth
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPreserveHost On
在 springboot 应用程序(application.yaml)中
server:
use-forward-headers: true
知道我可以做些什么来使它也能与 tomcat 一起工作吗? 您可以找到完整的代码(application.yml 除外,因为它目前保存着 oauth 的 secret )on github .
提前感谢任何想法!
最佳答案
Spring Boot 中的嵌入式 Tomcat 容器不支持开箱即用的转发 header 。参见 https://github.com/spring-projects/spring-boot/issues/6232 .我在这上面浪费了很多时间。
关于java - Proxy 背后的 SpringBoot 适用于 Undertow 但不适用于 Tomcat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47690733/