alaboudi
alaboudi

Reputation: 3413

How to test Https connections locally Apache

I think I may have a misconception

I am trying to include https in my local settings so that I dont have to keep changing every link in my application from http to https every time i upload it to my web host. I had downloaded bitnami for my local developement and im using apache. How can I use https in local environment? Do I not understand some fundamental? I keep hearing something about self-signed certificates. Does this apply to me?

Hope this is the right place for the question

Upvotes: 0

Views: 1324

Answers (1)

Francisco Ortiz
Francisco Ortiz

Reputation: 548

Bitnami developer here

About the first question, you can force https redirection for your application adding the following in the bitnami.conf (/installdir/apache2/conf/bitnami/bitnami.conf) file inside the default directive (in the example below using port 80):

<VirtualHost *:80>
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/(.*) https://%{SERVER_NAME}/$1 [R,L]
...
</VirtualHost>
<VirtualHost *:443>
...
</VirtualHost>

Please note that after modifying the Apache configuration files, you will need to restart Apache to apply the changes.

Regarding the self-signed certificates, you can follow these steps:

First create your private key (if you haven't created it already):

/installdir/common/bin/openssl genrsa -out /installdir/apache2/conf/server.key 2048

Later, the certificate request is created like this:

/installdir/common/bin/openssl req -new -key /installdir/apache2/conf/server.key -out /installdir/apache2/conf/cert.csr

While the certificate authority checks your request, you can create a temporary self-signed certificate:

/installdir/common/bin/openssl x509 -in /installdir/apache2/conf/cert.csr -out /installdir/apache2/conf/server.crt -req -signkey /installdir/apache2/conf/server.key -days 365

You can find more information about this in our wiki: https://wiki.bitnami.com/Components/Apache#How_to_create_a_SSL_certificate.3f

Upvotes: 2

Related Questions