我在加載Heroku中的Java Web應用程序時遇到了很多麻煩。Heroku中的SSL重定向
這是我有:
一個Java Web應用程序中使用Spring安全,在我的web.xml中的安全性約束部分,看起來像這樣(標準war文件):
<security-constraint>
<web-resource-collection>
<web-resource-name>SSL URLs</web-resource-name>
<url-pattern>/j_spring_security_check</url-pattern>
<url-pattern>/secure/account/create</url-pattern>
<url-pattern>/register</url-pattern>
<url-pattern>/login/*</url-pattern>
<url-pattern>/</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
當我將WAR文件部署到Heroku(使用Heroku部署插件用於Atlassian Bamboo)並啓動應用程序,結果在我的瀏覽器中出現了「太多重定向」錯誤 - 它看起來像是在https之間輕彈一下和http,但我無法弄清楚我需要做些什麼來解決它。
我現在只想使用搭載SSL,因爲SSL附加組件對於我的愛好項目(每月20美元)非常昂貴。
這可能是由於Heroku如何總是嚮應用程序發送http(不是https)。我有一個示例應用程序以不同的方式處理這個問題:https://github.com/jamesward/springmvc-https-enforcer不知道這是否有幫助。 –
嗯,所以它不是全部或沒有SSL呢? – JMM
不需要。但是您可能需要在Heroku上做一些額外的工作才能正確確定請求是否最初是https。你將不得不使用'x -forwarded-proto'請求頭。這可能有所幫助:http://stackoverflow.com/questions/5741210/handling-x-forwarded-proto-in-java-apache-tomcat –