【发布时间】:2022-01-19 14:41:35
【问题描述】:
我正在寻找一种能够在 Apache SSL 代理之后运行 Spring 应用程序的解决方案。我尝试了很多配置都没有成功。所有 Spring 响应都转到 http,导致 Not Found 错误。
以下是apache配置:
SetEnv proxy-initial-not-pooled 1
ProxyPreserveHost On
KeepAlive On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off
ServerName server.mydomain.dom
ProxyTimeout 600
ProxyPass /excluded !
RequestHeader set X-Forwarded-Proto https
RequestHeader set X-Forwarded-Port 443
ProxyPass / http://127.0.0.1:8081/
ProxyPassReverse / http://127.0.0.1:8081/
这些是 Spring 选项:
server.port=8081
server.forward-headers-strategy=NATIVE
#server.tomcat.redirect-context-root=false
server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto
server.tomcat.internal-proxies=.*
我在 Apache Tomcat/9.0.54 上使用 Spring Boot 2.5.6。 OS Apache 是在 Debian 9.13 上运行的 2.4.25 版本。
问题似乎是在登录应用程序并注销后发生的。如果我在登录操作后将 http 替换为 https,则可以导航到应用程序。在我注销之前,所有链接都可以正常工作。当我注销时,应用程序再次转到 http。
【问题讨论】:
标签: spring spring-boot tomcat