Ubuntu/RoundCube webmail force SSL

From Mana zināšanu grāmata

METHOD 1:

This method is the most recommended and it applies to any Linux distribution using both Apache or Nginx.

All you have to do is to go to directory were roundcube is located >> config and edit file defaults.inc.php

Assuming that roundcube is installed in /var/www/roundcube, you will have this command: sudo vi /var/www/roundcube/defaults.ing.php

Now look for the following two lines and change from:

$config['use_https'] = false;

to

$config['use_https'] = true;

This method is the easiest and should work. However if it is not working (like in my case) you may want to try another approach. Please read bellow:

METHOD2

All what we do using this method is to redirect any HTTP traffic to our webmail to HTTPS directly from Apache web server! Please note that it works only if your server is powered by Apache!

This is possible to do this directly from apache .conf file, but we will do it a little bit simple using an .htaccess file.

All you have to do is to create a .htaccess file with the following content:

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{HTTPS} !=on
   RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

and place it on the root of roundcube directory, where php files are located. This will force any incoming request to use HTTPS instead of HTTP.

That’s all, now you can read your emails a little bit more safe!