簡體   English   中英

Spring 帶有嵌入式 Tomcat 的引導在 Apache ZEA52C36203C5F99C3CE2442D531B1 后面

[英]Spring Boot with embedded Tomcat behind Apache SSL proxy

我正在尋找一種能夠在 Apache SSL 代理后面運行 Spring 應用程序的解決方案。 我嘗試了很多配置都沒有成功。 所有 Spring 響應 go 到 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。

我解決問題。 第一步是添加

server.tomcat.use-relative-redirects=true

application.properties中。 使用此指令,代理可以正常工作。

最后,我將 apache/應用程序配置為使用 AJP。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM