How to enable & force HTTPS on Apache2 Web Server on Ubuntu

HTTPS Configuration (with self-signed certificate)

“sudo a2enmod ssl”

“sudo a2ensite default-ssl”

With Apache2 now configured for HTTPS, restart the service to enable the new settings:

“sudo service apache2 restart”

Source: https://help.ubuntu.com/10.04/serverguide/httpd.html

To force https:

Enable mod_rewrite:

"sudo a2enmod rewrite"

Then add the following to “/etc/apache2/sites-available/default” (first thing after <VirtualHost *:80>):
RewriteEngine   on
RewriteCond     %{HTTPS} !=on
RewriteRule     ^(.*)$ https://%{HTTP_HOST}/$1 [L,R]

Finally restart your Apache2 Server again (or force-reload it if you wish):

“sudo service apache2 restart”

Source: http://www.linode.com/wiki/index.php/Apache2_SSL_in_Ubuntu

 

 

Advertisements

About SoCRaT

Research Support and Infrastructure Engineer, OSS & Linux Geek
This entry was posted in Uncategorized and tagged , , , . Bookmark the permalink.

One Response to How to enable & force HTTPS on Apache2 Web Server on Ubuntu

  1. Luca says:

    Thanks, it works for me!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s