2016-02-10 33 views
0

因此,我有一個運行在端口8080上的tomcat服務器和一個運行在端口80和443上的Apache服務器。我可以通過使用這些虛擬服務器將整個網站重定向到https主機:使用ProxyPass將HTTP頁面重定向到HTTPS到Tomcat服務器

<VirtualHost *:80> 
    Redirect permanent/https://localhost 
</VirtualHost> 

<VirtualHost _default_:443> 
    SSLEngine on 
    SSLCertificateFile /etc/httpd/crt/localhost.crt 
    SSLCertificateKeyFile /etc/httpd/crt/localhost.key 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

但是,想獲得它,使它只重定向到HTTPS時,網址爲localhost/#/loginlocalhost/catdapp/#/login

我曾嘗試以下:

<VirtualHost *:80> 
    Redirect permanent /#/login https://localhost/#/login 
    Redirect permanent /catdapp/#/login https://localhost/#/login 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass /#/login ! 
    ProxyPass /catdapp/#/login ! 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

其中沒有工作,在控制檯顯示它檢索http://localhost/catdapp/partials/login.html所以我試圖將其更改爲這樣:

<VirtualHost *:80> 
    Redirect permanent /catdapp/partials/login.html https://localhost/catdapp/partials/login.html 
    ProxyRequests off 
    ProxyPreserveHost on 
    ProxyPass /catdapp/partials/login.html ! 
    ProxyPass/http://localhost:8080/ 
    ProxyPassReverse/http://localhost:8080/ 
    ProxyPass /catdapp http://localhost:8080/ 
    ProxyPassReverse /catdapp http://localhost:8080/ 
</VirtualHost> 

,然後導致Firefox的控制檯輸出兩個錯誤:

GET http://localhost/catdapp/partials/login.html 301 Moved Permanently 
GET https://localhost/catdapp/partials/login.html 200 OK 

的Apache訪問日誌顯示:

"GET /catdapp/partials/login.html HTTP/1.1" 301 328 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0" 
"GET /catdapp/partials/login.html HTTP/1.1" 200 2054 "http://localhost" "Mozilla/5.0 (X11; Linux x84_64; rv:38.0) Gecko/20100101 Firefox/38.0" 

任何想法?

回答

0

#在客戶端處理,在瀏覽器中 - 我沒有看到它傳輸到服務器。

我不再擔心混合模式操作,只是無條件地將所有內容重定向到https並繼續:http/https混合模式下,您只會打開如此多的意外安全漏洞,會話泄漏或其他(現今)只是不值得麻煩。在https虛擬主機上添加一個HSTS header,在偶然使用錯誤協議(一旦客戶端已經看到HSTS頭,這應該是常態)的情況下,您甚至可以安全使用

請問消耗更多的服務器端資源?可能,有點。這很重要嗎?測量!如果您擁有值得保護的資源,將會排除會話信息泄漏,網絡釣魚,中間人攻擊等全部錯誤。

相關問題