Note: Currently new registrations are closed, if you want an account Contact us

Difference between revisions of "Poddery - Diaspora, Matrix and XMPP"

From Free Software Community of India
Jump to: navigation, search
(Update security measures)
(Added ufw conifguration)
Line 40: Line 40:
* Firewall enabled with only the ports we need opened. [ ufw tutorial]
* Firewall enabled with only the ports we need opened. [ ufw tutorial]
  sudo ufw default deny incoming
  sudo ufw default allow outgoing
  sudo ufw allow ssh
* fail2ban configured against brute force attacks
* fail2ban configured against brute force attacks

Revision as of 20:29, 8 January 2018

We run diaspora, xmpp and matrix services at Diaspora username and password can be used to access xmpp and matrix services. provides riot client (accessed by a web browser), which can be used to connect to any matrix server without installing a riot app/client.



We are on a C2S instance of bare metal cloud server.

  • 4 Dedicated x86 64bit Cores
  • 8GB Memory
  • 50GB SSD Disk
  • 1 Flexible public IPv4
  • 300Mbit/s Unmetered bandwidth
  • 2.5Gbit/s Internal bandwidth
  • €11.99 Per month

Due to performance issues we are migrating to a new server (C2M instance of with the following specs:

  • 8 Dedicated x86 64bit Cores
  • 16GB Memory
  • 50GB SSD Disk
  • 1 Flexible public IPv4
  • 500Mbit/s Unmeterd bandwidth
  • 5Gbit/s Internal bandwidth
  • €17.99 per month
  • Extra 150GB SSD
  • Total €20.99 per month

Operating System

We run debian 9 stretch image provided by scaleway, with latest security updates applied.

Hardening checklist

  • SSH password login disabled (allow only key based logins)
  • root SSH login disabled (use a normal user with sudo)


 PermitRootLogin no
 PasswordAuthentication no
  • Firewall enabled with only the ports we need opened. ufw tutorial
 sudo ufw default deny incoming
 sudo ufw default allow outgoing
 sudo ufw allow ssh
  • fail2ban configured against brute force attacks

System health check

  • There should be a data disk attached (added from
  • The attached disk (/dev/nbd2) should be an lvm physical volume (pvcreate /dev/nbd2). We cannot use it directly for encryption, so we use lvm.
  • /dev/data is an lvm volume group created from /dev/nbd2 (vgcreate data /dev/nbd2).
  • /dev/data/diaspora is an lvm logical volume (lvcreate -n diaspora /dev/data -L 93.5G).
  • /dev/mapper/diaspora is an encrypted device (cryptsetup luksFormat /dev/data/diaspora; cryptsetup luksOpen /dev/data/diaspora diaspora)
  • /dev/mapper/diaspora is an ext4 file system (mkfs.ext4 /dev/mapper/diaspora)
  • /var/lib/diaspora should be mounted (mount /dev/mapper/diaspora /var/lib/diaspora)
  • all critical data should be on /var/lib/diaspora.

/etc/init.d/mysql stop; mv /var/lib/mysql /var/lib/diaspora; ln /var/lib/diaspora/mysql /var/lib/diaspora mkdir /var/lib/diaspora/uploads; chown -R diaspora: /var/lib/diaspora/uploads;ln -s /var/lib/diaspora/uploads /usr/share/diaspora/public/uploads

Services health check

 systemctl status nginx # our web server front end for diaspora, xmpp and matrix
 systemctl status diaspora # diaspora service
 systemctl status matrix-synapse.service # synapse matrix server
 systemctl status prosody # prosody xmpp server
 systemctl status sslh # SSL/SSH multiplexer which allow us to provide multiple services via 443 port (to bypass stupid firewalls)

User Visible Services


Homepage and other static pages are maintained in our gitlab instance. You can change it directly in the master branch or send pull requests. You can edit it via web as well. repo is maintained as a sub module in repo. See this tutorial -> for working with git submodules.

SSL/TLS certificates

# letsencrypt certonly --webroot -w /usr/share/diaspora/public  -d -d -d -d -w /usr/share/diaspora/public/save -d
# cp  -L /etc/letsencrypt/live/ /etc/diaspora/ssl/
# cp -L /etc/letsencrypt/live/ /etc/diaspora/ssl/
# chown -R root:ssl-cert /etc/letsencrypt
# chmod g+r -R /etc/letsencrypt
# chmod g+x /etc/letsencrypt/*
# ls -l /etc/prosody/certs/
total 0
lrwxrwxrwx 1 root root 40 Mar 28 01:16 -> /etc/letsencrypt/live/
lrwxrwxrwx 1 root root 33 Mar 28 01:16 -> /etc/letsencrypt/live/
# crontab -e
30 2 * * 1 letsencrypt renew  >> /var/log/le-renew.log
32 2 * * 1 /etc/init.d/nginx reload
34 2 * * 1 /etc/init.d/prosody reload


We use diaspora-installer-mysql package from (stretch/contrib) See /usr/share/doc/diaspora-common/README for package specific configuration.


  • We use prosody and steps for setting up prosody is given at ->
  • We have enabled all XEPs conversations expect. We use sslh to multiplex diaspora and prosody on port 443.


Backend Services


Front end for diaspora and matrix.


Backend for matrix.


Backend for diaspora. TODO: consider migrating to PostgreSQL to optimize resources (we can reduce one service and RAM usage).


Port multiplexer to allow xmpp and diaspora to share 443 port. This allows us to fool stupid firewalls which blocks all ports except 80 and 443 (hence xmpp).



Email: poddery at (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)

The following people have their gpg keys in the password file.

Praveen Arimbrathodiyil (piratepin) (ID: 0xCE1F9C674512), Balasankar C (ID: 0x96EDAB9B2E6B7171), Manu Krishnan T V (ID: 0x5D0064186AF037D9), Fayad Fami (fayad) (ID: 0x51C954405D432381), Abhijith PA (ID: 0x863D4DF2ED9C28EF), Syam G Krishnan (sgk) (ID: 0x6EF48CCD865A1FFC), Sagar Ippalpalli (ID: 0xFD49D0BC6FEAECDA)

We recommend you setup vim gpg plugin for transparent editing. If you are new to gpg, then follow this guide.

Server Access

Maintained in a private git repo at ->

Setting up Backup

Backup was setup on a Scaleway C1 VPS (4 core ARM processor with 2GB RAM). TODO: C1 server was crashing frequently and we need to setup backup again on VPS provided by Manu.

Hostname (IP): (No public ip, access via web console). If you restart this machine, you may want to add private ip in /etc/hosts

# apt-get install lvm2 cryptsetup

Directly creating luks volume on /dev/nbd1 is not working, so we use a logical volume

# pvcreate /dev/nbd1
# vgcreate data /dev/nbd1
# lvcreate -n diaspora -L 46.5G /dev/data
# cryptsetup luksFormat /dev/data/diaspora
# cryptsetup luksOpen /dev/data/diaspora diaspora

and update /etc/crypttab

# <target name> <source device>         <key file>      <options>
diaspora /dev/data/diaspora none luks

# mkfs.ext4 /dev/mapper/diaspora
# mkdir /var/lib/diaspora

and update /etc/fstab

/dev/mapper/diaspora /var/lib/diaspora ext4 defaults 0 2
# mount -a
# apt-get install mysql-server

Move mysql data directory to encrypted volume

# /etc/init.d/mysql stop
# mv /var/lib/mysql /var/lib/diaspora/
# ln -s /var/lib/diaspora/mysql /var/lib/mysql

Follow steps in for replication

Follow steps in for ssl (but ssl support is disabled in debian)

Follow steps in to use ssh port forwarding to have encrypted replication

# adduser sshtunnel --disabled-login
# su sshtunnel

Generate ssh key pair and copy public key to target system

$ ssh-keygen -t rsa
$ ssh -f -L 7777: -N

Test the connectivity

# mysql -u poddery_backup -p -P 7777 -h

Uploads are rsynced every hour

# crontab -e
# m h  dom mon dow   command
0 * * * * pgrep rsync || rsync -av --delete /var/lib/diaspora/uploads/ >/var/lib/diaspora/rsync-uploads.log

Note: Since we are not using a public ip (saves us money), connects to via private ip. So if is rebooted, the new ip address should be updated in /etc/hosts file of To connect, use the web console from

Add more disk space

  1. Power off the machine with "ARCHIVE" option. It may take upto an hour for shutdown to complete on and
  2. Add more disk from control panel . Volumes -> CREATE VOLUME
  3. Attach the newly created volume to server from Server page
  4. Power on the server
  5. Create physical volume (pvcreate /dev/nbdN)
  6. Expand volume group (vgextend data /dev/nbdN)
  7. Expand logical volume (lvresize --size=186G data/diaspora)
  8. Expand encrypted partition (cryptsetup resize diaspora)
  9. Resize file system (resize2fs /dev/mapper/diaspora)

Maintenance history

This section holds maintenance/issue history for future tracking.

When updating diaspora-installer-mysql packages, remember to recreate /usr/share/diaspora/public/uploads symlink to /var/lib/diaspora/uploads.

1. Prosody error - Failed to load private key

certmanager error SSL/TLS: Failed to load '/etc/letsencrypt/live/': Previous error (see logs), or other system error. (for
tls error   Unable to initialize TLS: error loading private key (system lib)
certmanager error SSL/TLS: Failed to load '/etc/letsencrypt/live/': Check that the permissions allow Prosody to read this file.

This error is usually when ssl certificate in freshly installed or renewed. Prosody user is unable to access the key file due to lack of privileges.

Note that Poddery uses Letsencrypt for ssl.


  • Make sure that prosody user is in 'certs' group (this group may also be called ssl-certs as setup by Letencrypt)
  • /etc/letsencrypt/ is the ssl directory.
  • Prosody user should have permissions to all folders importantly archive and live folders in /etc/letsencrypt. Permissions to each folder must be 750.
  • Troubleshoot by checking if you can switch to each folder in /etc/letsencrypt as prosody user and cat the files.

If replication fails, you can restart it following the instructions here