Forcefully redirect HTTP requests to HTTPS in Bitnami Apache


In order to redirect http requests to https, we need to make some changes in the default apache configuration file. So, before we start, make sure to backup the current config file. So that we can revert the changes if something went wrong. The location of default configuration file in bitnami is “/opt/bitnami/apache2/conf/bitnami/bitnami.conf”.

sudo cp -apf /opt/bitnami/apache2/conf/bitnami/bitnami.conf /opt/bitnami/apache2/conf/bitnami/bitnami.conf_bak

Find the VirtualHost directive and add the following lines into it. It will look like:

<VistualHost _default_:80>
   DocumentRoot “/opt/bitnami/apache2/htdocs”
   RewriteEngine On
   RewriteCond %{HTTPS} !=on
   RewriteCond %{HTTP_HOST} !^(localhost|127.0.0.1)
   RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
   …
</VirtualHost>

Restart apache to apply the changes

sudo /opt/bitnami/ctlscript.sh restart apache

Post navigation

Alvin Jaison

Myself Alvin Jaison. I'm a DevOps Engineer by Profession; A Mountaineer by Passion. I started this website to share DevOps related posts. Post your suggestions as a comment. You can reach me @ alvinjaison@outlook.com

Leave a Reply

Your email address will not be published. Required fields are marked *