Bitnami Apache:将 HTTP 重写为 HTTPS

Bitnami Apache:将 HTTP 重写为 HTTPS

我正在尝试将 Bitnami LAMP 环境中的所有 HTTP 请求重定向到 HTTPS。

一开始我按照步骤这里但它不起作用。我也试过答案这个问题以及介于两者之间的一切。

这是我目前所拥有的。

bitnami.conf:

# Default Virtual Host configuration.  

# Let Apache know we're behind a SSL reverse proxy
SetEnvIf X-Forwarded-Proto https HTTPS=on

<VirtualHost _default_:80>  
    RewriteEngine On  
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)  
    RewriteRule ^(.*)$ https://XXXXXX.com$1 [R=permanent,L]  
    DocumentRoot "/opt/bitnami/apache/htdocs"  
    
    <Directory "/opt/bitnami/apache/htdocs">    
        Options Indexes FollowSymLinks    
        AllowOverride All    
        Require all granted  
    </Directory> 
    
    # Error Documents  
    ErrorDocument 503 /503.html

</VirtualHost>

Include "/opt/bitnami/apache/conf/bitnami/bitnami-ssl.conf"

bitnami-ssl.conf:

<IfModule !ssl_module>  
    LoadModule ssl_module modules/mod_ssl.so
</IfModule>

Listen 443
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
SSLPassPhraseDialog  builtin
SSLSessionCache "shmcb:/opt/bitnami/apache/logs/ssl_scache(512000)"
SSLSessionCacheTimeout  300

<VirtualHost _default_:443>
    RewriteEngine On  
    RewriteCond %{HTTP_HOST} !^XXXXXX.com$  
    RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1) 
    RewriteRule ^(.*)$ https://XXXXXXX.com$1 [R=permanent,L]  
    DocumentRoot "/opt/bitnami/apache/htdocs"  
    SSLEngine on  
    SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"  
    SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"  
    <Directory "/opt/bitnami/apache/htdocs">    
        Options Indexes FollowSymLinks    
        AllowOverride All    
        Require all granted  
    </Directory> 

    # Error Documents
    ErrorDocument 503 /503.html
</VirtualHost>

请帮忙,我为此绞尽了脑汁。是的,我已经重启了 Apache。

相关内容