Apache、虛擬主機、重定向、https、ssl 問題

Apache、虛擬主機、重定向、https、ssl 問題

問題:

重寫日誌中沒有針對這些錯誤的條目。

虛擬主機配置

<VirtualHost 127.0.1.3:80>
ServerAdmin [email protected]
ServerName www.example.com

DocumentRoot /var/www/html
<Directory /var/www/html>
    Options Indexes FollowSymLinks
    AllowOverride All


    Order allow,deny
    Allow from all
</Directory>


Redirect permanent /fundprocess.html https://example.com/fundprocess.html
Redirect permanent /fund_process.php https://example.com/fund_process.php

ErrorLog /var/log/apache2/example.com-error_log
TransferLog /var/log/apache2/example.com-access_log
LogLevel warn

RewriteLog /var/log/apache2/example.com-rewrite_log
RewriteLogLevel 9



</VirtualHost>


<VirtualHost 127.0.1.2:80>
ServerAdmin [email protected]
ServerName example.com
DocumentRoot /var/www/html

    RewriteCond %{REQUEST_URI} !fundprocess.html [NC]
    RewriteCond %{REQUEST_URI} !fund_process.php [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} fundprocess.html [NC]
    RewriteCond %{REQUEST_URI} fund_process.php [NC]
    RewriteRule (.*) https://example.com/$1 [R=301,L]



</VirtualHost>



<VirtualHost 127.0.1.3:443>
ServerAdmin [email protected]
ServerName www.example.com
DocumentRoot /var/www/html

    RewriteCond %{REQUEST_URI} !fundprocess.html [NC]
    RewriteCond %{REQUEST_URI} !fund_process.php [NC]
    RewriteRule (.*) http://www.example.com/$1 [R=301,L]

    RewriteCond %{REQUEST_URI} fundprocess.html [NC]
    RewriteCond %{REQUEST_URI} fund_process.php [NC]
    RewriteRule (.*) https://example.com/$1 [R=301,L]


</VirtualHost>



<VirtualHost 127.0.1.2:443>
ServerAdmin [email protected]
ServerName example.com


DocumentRoot /var/www/html
<Directory /var/www/html>

    Options Indexes FollowSymLinks
    AllowOverride All


    Order allow,deny
    Allow from all

 </Directory>


RewriteCond %{HTTPS} on
RewriteCond %{REQUEST_URI} !fundprocess.html [NC]
RewriteCond %{REQUEST_URI} !fund_process.php [NC]
RewriteRule (.*) http://www.example.com/$1 [R=301,L]

ErrorLog /var/log/apache2/example.com-ssl-error_log
TransferLog /var/log/apache2/example.com-ssl-access_log
LogLevel warn

RewriteLog /var/log/apache2/example.com-rewrite_log
RewriteLogLevel 9


SSLEngine On
SSLCertificateFile /etc/certs/example.crt
SSLCertificateKeyFile /etc/certs/example.key


SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

</VirtualHost>

答案1

這不是重定向的問題,而是 SSL 的問題(必須在重定向發生之前對請求進行解密)。

Listen 443你的 Apache 設定中有什麼地方嗎?如果不這樣做,請將其插入「Listen 80」部分附近。您是否在此伺服器上執行任何其他 SSL 網站?確保他們沒有使用相同的 IP 位址。最後,如果您確實有可以在其他地方使用的SSL 證書,請嘗試將其用於此網站- 它會在瀏覽器中發出警告,但如果您接受警告,它應該重定向- 那麼您就知道問題出在您的SSL 憑證上。

答案2

當 apache 期待 ssl 並接收 http 時,會發生 ssl_error_rx_record_too_long 。

確保所有連接埠 443 請求都到達帶有SSLEngine On.你需要修復你的<VirtualHost 127.0.1.3:443>.

此外,您的憑證需要同時適用於 example.com 和 *.example.com。否則,您的客戶將收到醜陋的警告而不是重定向。

相關內容