因此,我有一個運行在端口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/#/login
或localhost/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"
任何想法?