Score:1

Bitnami Apache: Rewrite HTTP to HTTPS

in flag

I'm trying to redirect all HTTP requests to HTTPS in a Bitnami LAMP environment.

At first I followed the steps here but it did not work. I also tried the answer of this question and basically everything in between.

Here is what I have currently.

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>

Please help, I've been pulling my hair out over this one. And yes I have been restarting apache.

Jota Martos avatar
cn flag
Bitnami Engineer here. Did you deploy a custom application on top of the LAMP solution? If you did so, you probably followed [this guide](https://docs.bitnami.com/aws/infrastructure/lamp/administration/create-custom-application-php/) and it explains you how to create a configuration file to serve that custom PHP application. In this case, you will also need to include the "Rewrite" configuration lines in those configuration files and restart Apache for the changes to take effect.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.