Setting up Roundcube with NGINX

Introduction

For a small install you might be happy-happy with SQlite, otherwise you need to go through the MariaDB guide first.

Preparing PHP for NGINX

see php

Preparing NGINX

Assuming the compression log format and nice ssl defaults have already been defined, add this virtual host

cd /etc/nginx/conf.d/
vi mail.conf

server {
        listen 80;
        server_name mail.nethence.com;
        return 301 https://mail.nethence.com$request_uri;
}

server {
        listen 443 ssl http2;
        server_name mail.nethence.com;

    ssl_certificate     /etc/dehydrated/certs/nethence_com/fullchain.pem;
    ssl_certificate_key /etc/dehydrated/certs/nethence_com/privkey.pem;
    ssl_certificate     /etc/dehydrated/certs/ECC/nethence_com/fullchain.pem;
    ssl_certificate_key /etc/dehydrated/certs/ECC/nethence_com/privkey.pem;

        #access_log logs/mail.access.log compression;
        #error_log  logs/mail.error.log warn;
        access_log /var/log/nginx/mail.access.log compression;
        error_log  /var/log/nginx/mail.error.log warn;

        root /data/www/$server_name;
        index index.php;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        location ~ ^/(README.md|INSTALL|LICENSE|CHANGELOG|UPGRADING)$ {
                deny all;
        }

        location ~ ^/(config|temp|logs)/ {
                deny all;
        }

        location ~ /\. {
                deny all;
                access_log off;
                log_not_found off;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }
}

Preparing Roundcube

Grab and extract the latest stable release Choose the complete version otherwise install the missing php Net_LDAP3 module somehow.

cd /data/www/

# dependent version
#wget https://github.com/roundcube/roundcubemail/releases/download/1.6.0/roundcubemail-1.6.0.tar.gz
#tar xzf roundcubemail-1.6.0.tar.gz
#rm -f roundcubemail-1.6.0.tar.gz

# complete version
wget https://github.com/roundcube/roundcubemail/releases/download/1.6.0/roundcubemail-1.6.0-complete.tar.gz
tar xzf roundcubemail-1.6.0-complete.tar.gz
rm -f roundcubemail-1.6.0-complete.tar.gz

mv roundcubemail-1.6.0/ mail.nethence.com/
chown -R www-data. mail.nethence.com/

either prepare a MariaDB DB

–or– prepare a space for an SQLite DB

mkdir /var/lib/sqlite-roundcube/
chown -R www-data. /var/lib/sqlite-roundcube/

Ready to go

Watch the logs and apply

tail -F /var/log/nginx/mail.error.log &
nginx -t
nginx -s reload

that one should redirect to HTTPS

curl -i http://mail.nethence.com/

now for that now, check that you get a 200 with the Oops... something went wrong! message and no error in the logs

curl -i https://mail.nethence.com/

then proceed with the online installer

https://mail.nethence.com/installer/

eventually tune a few defaults

support_url --> https://nethence.com/contact
identities_level --> one identify allow change but email address
log_driver --> syslog
imap_host --> ssl://localhost:993
smtp_host --> ssl://localhost:465
language --> en_US
page size --> 120
addressbook size --> 120

CREATE CONFIG

CONTINUE

eventually tweak the config manually

cd /data/www/mail.nethence.com/
cp -pi config/config.inc.php config/config.inc.php.from-installer
vi config/config.inc.php

$config['db_dsnw'] = 'sqlite:////var/lib/sqlite-roundcube/roundcubemail.db?mode=0646';
$config['imap_host'] = 'ssl://localhost:993';
$config['support_url'] = 'https://nethence.com/contact';
$config['des_key'] = '24-CHARS-PASSPHRASE-HERE';
$config['plugins'] = [];
$config['enable_spellcheck'] = true;

$config['enable_installer'] = false;

fix folder perms and remove the wizard

chown -R root. /data/www/mail.nethence.com/
chown -R www-data. /data/www/mail.nethence.com/{temp,logs}/
rm -rf /data/www/mail.nethence.com/installer/

Custom logo

apt install imagemagick
identify skins/classic/images/roundcube_logo.png

cd images/
convert -resize 178x47 nethence-5lineoblique.png nethence-5lineoblique.178x47.png
convert -resize 178x47 nethence-bigchief.png nethence-bigchief.178x47.png
ln -sf nethence-bigchief.178x47.png nethence.png
cd ../

vi config/config.inc.php

$config['skin'] = 'classic';
$config['skin_logo'] = 'images/nethence.png';

Note. don’t forget either symlink or use the images/ folder within the roundcube served folder or use full https url, otherwise you might get ssl warnings that part of the content is not secured.

Resources

https://www.rudraraj.net/how-to-install-roundcube-with-nginx/

https://wiki.archlinux.org/index.php/Roundcube

https://www.howtoforge.com/running-roundcube-0.7.1-on-nginx-lemp-on-debian-squeeze-ubuntu-11.10

https://github.com/roundcube/roundcubemail/wiki/Configuration


HOME | GUIDES | LECTURES | LAB | SMTP HEALTH | HTML5 | CONTACT
Copyright © 2024 Pierre-Philipp Braun