我正在尋找能夠在 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。作業系統 Apache 是在 Debian 9.13 上運行的 2.4.25 版本。
問題似乎發生在登錄應用程式并注銷后。如果我在登錄操作后將 http 替換為 https,我就可以導航到應用程式中。在我注銷之前,所有鏈接都可以正常作業。當我注銷時,應用程式再次轉到 http。
uj5u.com熱心網友回復:
我解決了這個問題。第一步是添加
server.tomcat.use-relative-redirects=true
在application.properties 中。使用此指令,代理可以正常作業。
最后,我將 apache/application 配置為使用 AJP。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/389841.html
