Note: Currently new registrations are closed, if you want an account Contact us
Difference between revisions of "Poddery - Diaspora, Matrix and XMPP"
(Changed order of SSL configuration)
|Line 135:||Line 135:|
=== sslh ===
=== sslh ===
Port multiplexer to allow XMPP and
Port multiplexer to allow XMPP and share 443 port. This allows us to fool stupid firewalls which blocks all ports except 80 and 443 (hence XMPP).
=== SSL/TLS certificates ===
=== SSL/TLS certificates ===
Revision as of 12:10, 9 January 2018
We run Diaspora, XMPP and Matrix services at poddery.com. Diaspora username and password can be used to access XMPP and Matrix services. chat.poddery.com provides Riot client (accessed by a web browser), which can be used to connect to any Matrix server without installing a Riot app/client.
- 1 Environment
- 1.1 Hosting
- 1.2 Operating System
- 1.3 User Visible Services
- 1.4 Backend Services
- 2 Coordination
- 3 Setting up Backup
- 4 Add more disk space
- 5 Maintenance history
We are on a C2S instance of scaleway.com 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 scaleway.com) 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
We run Debian 9 Stretch image provided by Scaleway, with latest security updates applied.
- 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 sudo ufw enable
Currently ufw is disabled as it is crashing the server.
- fail2ban configured against brute force attacks
... LogLevel VERBOSE ...
sudo systemctl restart ssh sudo systemctl enable fail2ban sudo systemctl start fail2ban
Check /var/log/fail2ban.log for logs
Unban an IP:
sudo fail2ban-client set sshd unbanip <banned_ip>
Here sshd is the defaut jail name, change it if you are using a different jail.
System health check
- There should be a data disk attached (added from cloud.scaleway.com)
- The attached disk (/dev/nbdX) should be an lvm physical volume. We cannot use it directly for encryption, so we use lvm.
# Make sure lvm2 and udev packages are installed sudo apt-get install lvm2 udev # Replace X with valid number according to lsblk sudo pvcreate /dev/nbdX
- /dev/data is an lvm volume group created from /dev/nbdX
sudo vgcreate data /dev/nbdX
- /dev/data/diaspora is an lvm logical volume
sudo lvcreate -n diaspora /dev/data -L <size_of_disk>
- /dev/mapper/diaspora is an encrypted device
# Make sure cryptsetup package is installed sudo apt-get install cryptsetup
# Give disk encryption password as specified in the access repo sudo cryptsetup luksFormat /dev/data/diaspora sudo cryptsetup luksOpen /dev/data/diaspora diaspora
- /dev/mapper/diaspora is an ext4 file system
sudo mkfs.ext4 /dev/mapper/diaspora
- /var/lib/diaspora should be mounted. All critical data should be on /var/lib/diaspora.
sudo mkdir /var/lib/diaspora sudo mount /dev/mapper/diaspora /var/lib/diaspora
User Visible Services
- We use diaspora-installer-mysql package from https://people.debian.org/~praveen/diaspora/README
- See /usr/share/doc/diaspora-common/README for package specific configuration.
- live statistics
- We use Prosody and steps for setting up Prosody is given at -> https://wiki.debian.org/Diaspora/XMPP
- We have enabled all XEPs conversations expect. We use sslh to multiplex Diaspora and Prosody on port 443.
- We use Synapse server for setting up the Matrix server.
- We will be using https://github.com/matrix-org/synapse/#synapse-installation for setting up this instance
- We use nginx reverse proxy to send requests that has /_matrix/* in url to synapse on 8008. See /etc/nginx/sites-enabled/diaspora
- We use https://git.fosscommunity.in/necessary129/synapse-diaspora-auth to authenticate synapse with Diaspora database.
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.
- poddery.com -> https://git.fosscommunity.in/community/poddery.com
- save.poddery.com -> https://git.fosscommunity.in/community/save.poddery.com
save.poddery.com repo is maintained as a sub module in poddery.com repo. See this tutorial -> https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ for working with git submodules.
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).
# letsencrypt certonly --webroot -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com # cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem # cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key # 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 poddery.com.crt -> /etc/letsencrypt/live/poddery.com/fullchain.pem lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -> /etc/letsencrypt/live/poddery.com/privkey.pem
# 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
Handling critical data
sudo /etc/init.d/mysql stop sudo mv /var/lib/mysql /var/lib/diaspora sudo ln /var/lib/diaspora/mysql /var/lib/diaspora sudo mkdir /var/lib/diaspora/uploads sudo chown -R diaspora: /var/lib/diaspora/uploads sudo 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)
- loomio group - we use this for decision making.
- Hangout with us in our Matrix room #poddery:poddery.com
Email: poddery at autistici.org (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), Pirate Bady (piratesin) (ID: 0x92FDAB42A95FF20C), Kannan (ID: 0x0B1955F40C691CCE)
Maintained in a private git repo at -> https://git.fosscommunity.in/community/access
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): backup.poddery.com (No public ip, access via scaleway.com web console). If you restart this machine, you may want to add poddery.com 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
# UNCONFIGURED FSTAB FOR BASE SYSTEM /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 https://dev.mysql.com/doc/refman/5.5/en/replication-howto-masterbaseconfig.html for replication
Follow steps in https://www.howtoforge.com/how-to-set-up-mysql-database-replication-with-ssl-encryption-on-centos-5.4 for ssl (but ssl support is disabled in debian)
Follow steps in http://www.networkcomputing.com/storage/how-set-ssh-encrypted-mysql-replication/1111882674 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 email@example.com -L 7777:127.0.0.1:3306 -N
Test the connectivity
# mysql -u poddery_backup -p -P 7777 -h 127.0.0.1
Uploads are rsynced every hour
# crontab -e # m h dom mon dow command 0 * * * * pgrep rsync || rsync -av --delete firstname.lastname@example.org:/var/lib/diaspora/uploads/ /var/lib/diaspora/uploads/ >/var/lib/diaspora/rsync-uploads.log
Note: Since we are not using a public ip (saves us money), backup.poddery.com connects to poddery.com via private ip. So if poddery.com is rebooted, the new ip address should be updated in /etc/hosts file of backup.poddery.com. To connect, use the web console from scaleway.com
Add more disk space
- Power off the machine with "ARCHIVE" option. It may take upto an hour for shutdown to complete on backup.poddery.com and poddery.com
- Add more disk from scaleway.com control panel . Volumes -> CREATE VOLUME
- Attach the newly created volume to server from Server page
- Power on the server
- Create physical volume (pvcreate /dev/nbdN)
- Expand volume group (vgextend data /dev/nbdN)
- Expand logical volume (lvresize --size=186G data/diaspora)
- Expand encrypted partition (cryptsetup resize diaspora)
- Resize file system (resize2fs /dev/mapper/diaspora)
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/poddery.com/privkey.pem': Previous error (see logs), or other system error. (for poddery.com) tls error Unable to initialize TLS: error loading private key (system lib) certmanager error SSL/TLS: Failed to load '/etc/letsencrypt/live/poddery.com/privkey.pem': 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