<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.fsci.in/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ravi</id>
	<title>FSCI Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.fsci.in/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Ravi"/>
	<link rel="alternate" type="text/html" href="https://wiki.fsci.in/Special:Contributions/Ravi"/>
	<updated>2026-06-01T01:38:16Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.2</generator>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=NUUP&amp;diff=11196</id>
		<title>NUUP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=NUUP&amp;diff=11196"/>
		<updated>2026-01-12T16:23:27Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Directly Opening a specific screen */ Reword&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[File:*99- USSD.png|alt=USSD Sample|thumb|*99# USSD]]&lt;br /&gt;
&lt;br /&gt;
The National Unified USSD Platform (NUUP) lets you use UPI by dialling *99#, without having to install a proprietary app.&lt;br /&gt;
&lt;br /&gt;
The service is run by the National Payments Corporation of India (NPCI), the government-backed private company that also operates the UPI ecosystem itself.&lt;br /&gt;
&lt;br /&gt;
== *99# and BHIM ==&lt;br /&gt;
Besides NUUP, NPCI also operates BHIM which is a proprietary app for Android smartphones. The two are linked in the sense that dialling *99# is essentially a different way of accessing your BHIM account. Practically, this means that if you run into issues setting up UPI payments with *99#, you can often work around this by borrowing a proprietary Android phone from someone and installing BHIM on that to link your bank and set up UPI payments. Once done, you can uninstall the app and make payments directly via *99#.&lt;br /&gt;
&lt;br /&gt;
== Provider support ==&lt;br /&gt;
While NUUP is theoretically supposed to work on all USSD supporting carriers in India (all the provider apart from Jio), the service is not very well maintained and keeps going down, or, in some cases, doesn&#039;t work at all.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|+ Provider support for *99#&lt;br /&gt;
|-&lt;br /&gt;
! Provider !! Officially supported !! Actually working&lt;br /&gt;
|-&lt;br /&gt;
| Airtel   || {{Tick}}             || {{Tick}}&lt;br /&gt;
|-&lt;br /&gt;
| BSNL     || {{Tick}}             || {{Cross}}&lt;br /&gt;
|-&lt;br /&gt;
| Jio      || {{Cross}}            || {{Cross}}&lt;br /&gt;
|-&lt;br /&gt;
| MTNL     ||                      ||&lt;br /&gt;
|-&lt;br /&gt;
| Vi       || {{Tick}}             || {{Tick}} but can pay only to mobile numbers and not full upi ids. collect requests works.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[File:Nuup-vi.png|alt=USSD failure with vi|thumb|Vi failing with UPI ID]]&lt;br /&gt;
&lt;br /&gt;
== Bank support ==&lt;br /&gt;
The NPCI [https://www.npci.org.in/what-we-do/99/live-members lists 103 banks] supporting *99# payments. However, each of them has their own slightly different interface to the service, and not all of them work seamlessly.&lt;br /&gt;
&lt;br /&gt;
This section provides crowdsourced information on which banks have been known to work or not, as experienced by the FSCI community.&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|+ Bank feature support on *99#&lt;br /&gt;
|-&lt;br /&gt;
! Bank                     !! Available on service !! Registration (if UPI PIN not set) !! Registration (if UPI PIN already set) !! Accepting payment request !! Receiving money!! Payment to beneficiary !! Payment to UPI ID !! Payment to Mobile Number !! Payment to Account/IFSC !! Setting UPI ID&lt;br /&gt;
|-&lt;br /&gt;
| City Union Bank          || {{Tick}}             || {{Cross}} Sends an SMS regarding UPI activation as well as an OTP, but USSD only says to &amp;quot;keep your debit card ready&amp;quot; and doesn&#039;t accept further input || {{Tick}}             || {{Tick}}                  || {{Tick}}       ||                        || {{Cross}} truncates at `@` and claims &amp;quot;invalid UPI ID&amp;quot; ||  ||           || {{Tick}}&lt;br /&gt;
|-&lt;br /&gt;
| Federal Bank             || {{Tick}}             ||                                   || {{Tick}}             ||                                                ||                ||                       ||                                 yes||                                 yes|| ||&lt;br /&gt;
|-&lt;br /&gt;
| Kotak Bank             || {{Tick}}             ||                                   || {{Tick}}             ||                                                ||                ||                       ||                                 yes||                                 yes|| ||&lt;br /&gt;
|-&lt;br /&gt;
| ICICI                    || {{Tick}}             || {{Tick}} || {{Tick}}             ||                                        ||                ||             || {{Tick}} on Airtel, but {{Cross}} on vi, which truncates at `@` and claims &amp;quot;invalid UPI ID&amp;quot;                   ||   {{Tick}}      ||            || &lt;br /&gt;
|-&lt;br /&gt;
| India Post Payments Bank || {{Cross}} Supposedly listed, but not actually present || {{Cross}} || {{Cross}}                   || {{Cross}}           ||                || {{Cross}}             || {{Cross}}                          || {{Cross}}                       || {{Cross}}               || {{Cross}}&lt;br /&gt;
|-&lt;br /&gt;
| Indian Bank              || {{Tick}}             || {{Cross}} Allows debit card based registration but goes into loop due to bug with 6 digit PIN vs. 4 digit PIN                              || {{Tick}}             || {{Tick}}                                       || {{Tick}}       || {{Tick}}         || {{Cross}} truncates at `@` and claims &amp;quot;invalid UPI ID&amp;quot; || {{Tick}} ||   || {{Tick}}&lt;br /&gt;
|-&lt;br /&gt;
|Central Bank of India&lt;br /&gt;
|{{Tick}}&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|{{Tick}}&lt;br /&gt;
|{{Tick}}&lt;br /&gt;
|{{Tick}}&lt;br /&gt;
|&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== City Support ==&lt;br /&gt;
It is observed to be working only in selected cities.&lt;br /&gt;
&lt;br /&gt;
Confirmed working: Bengaluru, Kochi, Mumbai, Gurugram&lt;br /&gt;
&lt;br /&gt;
Confirmed not working: Ahmedabad, Kolkata, Palakkad, Pune, Surat, Coimbatore&lt;br /&gt;
&lt;br /&gt;
== Limitations ==&lt;br /&gt;
Dynamic QR codes generated by payment machines don&#039;t work. Only fixed QR codes / UPI ids work.&lt;br /&gt;
&lt;br /&gt;
== UPI URL format ==&lt;br /&gt;
Currently we can only copy the whole URL in most QR scanning apps, so we have to manually extract the UPI id when making payments via *99# ussd interface or in android without google play service, upi apps can&#039;t scan directly, so you still need to extract the upi id manually).&lt;br /&gt;
&lt;br /&gt;
UPI url looks like upi://pay?pa=Motilal2005@hdfcbank&amp;amp;pn=MOFSL&amp;amp;mc=6021&amp;amp;tr=uft_2288daf8bd45a5&amp;amp;tn=Pay%2520to%2520MOFSL&amp;amp;mode=03&amp;amp;am=100&amp;amp;cu=INR&lt;br /&gt;
&lt;br /&gt;
Here UPI id is the value of pa, ie, Motilal2005@hdfcbank&lt;br /&gt;
&lt;br /&gt;
See https://source.puri.sm/Librem5/millipixels/-/issues/98 for adding support to extract UPI id in millipixels.&lt;br /&gt;
&lt;br /&gt;
== Collect Requests ==&lt;br /&gt;
Businesses can still initiate collect requests - for example payment gateways (tested with RazorPay page). You enter your UPI id on the webpage and diasl *99#, it will directly show the accept request screen, you can enter the pin to approve the request.&lt;br /&gt;
[[File:Upi-Collect-Request.png|alt=UPI Collect Request screenshot|thumb|UPI Collect Request]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Note:&#039;&#039;&#039; Starting 1 October 2025, UPI collect request will [https://www.angelone.in/news/personal-finance/upi-collect-requests-to-end-from-october-1-what-phonepe-google-pay-paytm-users-must-know no longer be available for individuals] although it will still be available for businesses as well as online payments. The ostensible reason is to prevent &amp;quot;fraud&amp;quot; from people misusing the collect request functionality. Specifically, this means it will not be possible to ask people to request money in case adding via UPI ID is not working. Some UPI apps like Paytm and PhonePe have already stopped offering this feature.&lt;br /&gt;
&lt;br /&gt;
Collect requests works with RazorPay page but fails with Airtel Recharge.&lt;br /&gt;
&lt;br /&gt;
== Directly Opening a specific screen ==&lt;br /&gt;
Choices can be sent directly as well. *99*1# opens the screen to send money directly, whereas *99*1*3# takes you to the screen to enter the UPI ID. So with this the camera app itself could add a pay option if upi:// URL is detected and dial *99*1*3# and fill the UPI id, so we can emulate the scan and pay - then people will only have to enter pin manually!&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
# [[Making payments using Free Software]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11117</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11117"/>
		<updated>2025-10-11T19:06:02Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* TLS */ Update certificate renewal steps&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social network, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com chat.poddery.com] provides Element client (accessed by a web browser), which can be used to connect to any Matrix server without installing the Element app.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service &lt;br /&gt;
 matrix-synapse@federation_reader.service &lt;br /&gt;
 matrix-synapse@event_creator.service &lt;br /&gt;
 matrix-synapse@federation_sender.service &lt;br /&gt;
 matrix-synapse@pusher.service &lt;br /&gt;
 matrix-synapse@user_dir.service &lt;br /&gt;
 matrix-synapse@media_repository.service &lt;br /&gt;
 matrix-synapse@frontend_proxy.service &lt;br /&gt;
 matrix-synapse@client_reader.service &lt;br /&gt;
 matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===SSL certificate renewal===&lt;br /&gt;
On the 12th of October 2025, all the certificates were removed and were recreated. [https://codema.in/d/XUfAOrPW/poddery-server-certificates-recreated This thread] documents all those steps.&lt;br /&gt;
&lt;br /&gt;
When renewing certificates on the poddery server, make sure to follow the following steps.&lt;br /&gt;
&lt;br /&gt;
# Stop nginx by running&lt;br /&gt;
 sudo systemctl stop nginx&lt;br /&gt;
&lt;br /&gt;
# Renew certificates for all the domains&lt;br /&gt;
 sudo certbot renew&lt;br /&gt;
&lt;br /&gt;
Follow the prompts by certbot to renew certificates for all the domains.&lt;br /&gt;
&lt;br /&gt;
# Start nginx after the renewal is successful&lt;br /&gt;
 sudo systemctl start nginx&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11116</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11116"/>
		<updated>2025-10-07T20:44:50Z</updated>

		<summary type="html">&lt;p&gt;Ravi: Fix 1 spelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social network, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com chat.poddery.com] provides Element client (accessed by a web browser), which can be used to connect to any Matrix server without installing the Element app.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service &lt;br /&gt;
 matrix-synapse@federation_reader.service &lt;br /&gt;
 matrix-synapse@event_creator.service &lt;br /&gt;
 matrix-synapse@federation_sender.service &lt;br /&gt;
 matrix-synapse@pusher.service &lt;br /&gt;
 matrix-synapse@user_dir.service &lt;br /&gt;
 matrix-synapse@media_repository.service &lt;br /&gt;
 matrix-synapse@frontend_proxy.service &lt;br /&gt;
 matrix-synapse@client_reader.service &lt;br /&gt;
 matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11115</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11115"/>
		<updated>2025-10-07T20:42:59Z</updated>

		<summary type="html">&lt;p&gt;Ravi: Replace Riot with Element&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com chat.poddery.com] provides Element client (accessed by a web browser), which can be used to connect to any Matrix server without installing the Element app.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service &lt;br /&gt;
 matrix-synapse@federation_reader.service &lt;br /&gt;
 matrix-synapse@event_creator.service &lt;br /&gt;
 matrix-synapse@federation_sender.service &lt;br /&gt;
 matrix-synapse@pusher.service &lt;br /&gt;
 matrix-synapse@user_dir.service &lt;br /&gt;
 matrix-synapse@media_repository.service &lt;br /&gt;
 matrix-synapse@frontend_proxy.service &lt;br /&gt;
 matrix-synapse@client_reader.service &lt;br /&gt;
 matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11114</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11114"/>
		<updated>2025-10-07T13:10:41Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Workers */ It was very hard to distinguish one service from the other in the previous list. So, I made a new line for each of the services.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service &lt;br /&gt;
 matrix-synapse@federation_reader.service &lt;br /&gt;
 matrix-synapse@event_creator.service &lt;br /&gt;
 matrix-synapse@federation_sender.service &lt;br /&gt;
 matrix-synapse@pusher.service &lt;br /&gt;
 matrix-synapse@user_dir.service &lt;br /&gt;
 matrix-synapse@media_repository.service &lt;br /&gt;
 matrix-synapse@frontend_proxy.service &lt;br /&gt;
 matrix-synapse@client_reader.service &lt;br /&gt;
 matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11050</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11050"/>
		<updated>2025-01-08T08:54:19Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Prosody */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service matrix-synapse@federation_reader.service matrix-synapse@event_creator.service matrix-synapse@federation_sender.service matrix-synapse@pusher.service matrix-synapse@user_dir.service matrix-synapse@media_repository.service matrix-synapse@frontend_proxy.service matrix-synapse@client_reader.service matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11049</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11049"/>
		<updated>2025-01-08T08:48:07Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Prosody */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service matrix-synapse@federation_reader.service matrix-synapse@event_creator.service matrix-synapse@federation_sender.service matrix-synapse@pusher.service matrix-synapse@user_dir.service matrix-synapse@media_repository.service matrix-synapse@frontend_proxy.service matrix-synapse@client_reader.service matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup-2024-10-27.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Backup of `/var/lb/prosody` was taken using following steps:&lt;br /&gt;
&lt;br /&gt;
* Create a tar file of prosody directory &lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd /var/lib &amp;amp;&amp;amp; sudo tar -czvf ~user/var.lib.prosody-2025-01-07.tar.gz prosody&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Make user as owner of compressed file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
cd &amp;amp;&amp;amp; chown user: var.lib.prosody-2025-01-07.tar.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Use `scp` to transfer tar file to the backup-server&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
scp -P &amp;lt;port-for-ssh-on-backup-server&amp;gt; ./var.lib.prosody-2025-01-07.tar.gz backup-user@backup-server:directory-to-backup&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11048</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11048"/>
		<updated>2025-01-08T08:41:26Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Backup steps on 7th Jan 2025 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service matrix-synapse@federation_reader.service matrix-synapse@event_creator.service matrix-synapse@federation_sender.service matrix-synapse@pusher.service matrix-synapse@user_dir.service matrix-synapse@media_repository.service matrix-synapse@frontend_proxy.service matrix-synapse@client_reader.service matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up: &lt;br /&gt;
&lt;br /&gt;
* Dump of postgresql database using `pg_dump`&lt;br /&gt;
* `/etc/matrix-synapse` - contains config files&lt;br /&gt;
* `/var/lib/static/synapse/media` -- contains uploaded media files&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
eval &amp;quot;$(ssh-agent -s)&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;followed by&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; synapse-2025-01-07.dump&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
For backing up prosody, the following were copied:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup-2024-10-27.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11047</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11047"/>
		<updated>2025-01-08T08:35:29Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Prosody */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service matrix-synapse@federation_reader.service matrix-synapse@event_creator.service matrix-synapse@federation_sender.service matrix-synapse@pusher.service matrix-synapse@user_dir.service matrix-synapse@media_repository.service matrix-synapse@frontend_proxy.service matrix-synapse@client_reader.service matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up:&lt;br /&gt;
- Dump of postgresql using `pg_dump`&lt;br /&gt;
- `/etc/matrix-synapse`&lt;br /&gt;
- `/var/lib/static/synapse/media`&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&lt;br /&gt;
&lt;br /&gt;
`eval &amp;quot;$(ssh-agent -s)&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
followed by&lt;br /&gt;
&lt;br /&gt;
`ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;`&lt;br /&gt;
on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&lt;br /&gt;
&lt;br /&gt;
`ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; poddery-backups/matrix-synapse/synapse-2025-01-07.dump`&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
The following were backed up for  prosody:&lt;br /&gt;
&lt;br /&gt;
* Dump of the database using `mysqldump` &lt;br /&gt;
* `/var/lib/prosody` for media files&lt;br /&gt;
* `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup-2024-10-27.sql.gz&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11046</id>
		<title>Poddery - Diaspora, Matrix and XMPP</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Poddery_-_Diaspora,_Matrix_and_XMPP&amp;diff=11046"/>
		<updated>2025-01-08T08:31:33Z</updated>

		<summary type="html">&lt;p&gt;Ravi: Add backup steps&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We run decentralized and federated [https://diasporafoundation.org/ Diaspora] social netowrk, [https://xmpp.org/ XMPP] and [https://matrix.org Matrix] instant messaging services at [https://poddery.com poddery.com]. Along with Diaspora, Poddery username and password can be used to access XMPP and Matrix services as well. [https://chat.poddery.com 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.&lt;br /&gt;
&lt;br /&gt;
= Environment =&lt;br /&gt;
== Hosting ==&lt;br /&gt;
Poddery is hosted at [https://www.hetzner.com Hetzner] with the following specs:&lt;br /&gt;
&lt;br /&gt;
* Intel Xeon E3-1246V3 Process - 4 Cores, 3.5GHz&lt;br /&gt;
* 4TB HDD&lt;br /&gt;
* 32GB DDR3 RAM&lt;br /&gt;
&lt;br /&gt;
== Operating System ==&lt;br /&gt;
* Debian Buster&lt;br /&gt;
&lt;br /&gt;
== User Visible Services ==&lt;br /&gt;
=== Diaspora ===&lt;br /&gt;
* Currently installed version is 0.7.6.1 which is available in [https://packages.debian.org/buster/diaspora-installer Debian Buster contrib]&lt;br /&gt;
* For live statistics see https://poddery.com/statistics&lt;br /&gt;
&lt;br /&gt;
=== Chat/XMPP ===&lt;br /&gt;
* [https://prosody.im/ Prosody] is used as the XMPP server which is modern and lightweight.&lt;br /&gt;
* Currently installed version is 0.11.2 which is available in [https://packages.debian.org/buster/prosody Debian Buster].&lt;br /&gt;
* All XEPs are enabled which the [https://conversations.im/ Conversations app] support.&lt;br /&gt;
&lt;br /&gt;
=== Chat/Matrix ===&lt;br /&gt;
* [https://matrix.org/docs/projects/server/synapse.html Synapse] is used as the Matrix server.&lt;br /&gt;
* Synapse is currently installed directly from the [https://github.com/matrix-org/synapse official GitHub repo].&lt;br /&gt;
* Riot-web Matrix client is hosted at https://chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
=== Homepage ===&lt;br /&gt;
Homepage and other static pages are maintained in FSCI [https://git.fosscommunity.in GitLab instance]. &lt;br /&gt;
* poddery.com -&amp;gt; https://git.fosscommunity.in/community/poddery.com&lt;br /&gt;
* save.poddery.com -&amp;gt; https://git.fosscommunity.in/community/save.poddery.com&lt;br /&gt;
* fund.poddery.com -&amp;gt; https://git.fosscommunity.in/community/fund-poddery&lt;br /&gt;
&lt;br /&gt;
== Backend Services ==&lt;br /&gt;
=== Web Server / Reverse Proxy ===&lt;br /&gt;
* Nginx web server which also acts as front-end (reverse proxy) for Diaspora and Matrix.&lt;br /&gt;
&lt;br /&gt;
=== Database ===&lt;br /&gt;
* PostgreSQL for Matrix&lt;br /&gt;
* MySQL for Diaspora&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;TODO&#039;&#039;: Consider migrating to PostgreSQL to optimize resources (We can reduce one service and RAM usage).&lt;br /&gt;
&lt;br /&gt;
=== Email ===&lt;br /&gt;
* Exim&lt;br /&gt;
&lt;br /&gt;
=== SSL/TLS certificates ===&lt;br /&gt;
* Let&#039;s Encrypt&lt;br /&gt;
&lt;br /&gt;
=== Firewall ===&lt;br /&gt;
* UFW (Uncomplicated Firewall)&lt;br /&gt;
&lt;br /&gt;
=== Intrusion Prevention ===&lt;br /&gt;
* Fail2ban&lt;br /&gt;
&lt;br /&gt;
= Coordination =&lt;br /&gt;
* [https://codema.in/g/2bjVXqAu/fosscommunity-in-poddery-com-maintainer-s-group Loomio group] - Mainly used for decision making&lt;br /&gt;
* Matrix room - [https://matrix.to/#/#poddery:poddery.com #poddery:poddery.com] also bridged to xmpp [xmpp:poddery.com-support@chat.yax.im?join poddery.com-support@chat.yax.im]&lt;br /&gt;
* [https://git.fosscommunity.in/community/poddery.com/issues Issue tracker] - Used for tracking progress of tasks&lt;br /&gt;
&lt;br /&gt;
=== Contact ===&lt;br /&gt;
* Email: poddery at autistici.org (alias that reaches Akhilan, Abhijith Balan, Fayad, Balasankar, Julius, Praveen, Prasobh, Sruthi, Shirish, Vamsee and Manukrishnan)&lt;br /&gt;
* The following people have their GPG keys in the [[#Server_Access|access file]]:&lt;br /&gt;
** ID: 0xCE1F9C674512C22A - Praveen Arimbrathodiyil (piratepin)&lt;br /&gt;
** ID: 0xB77D2E2E23735427 - Balasankar C&lt;br /&gt;
** ID: 0x5D0064186AF037D9 - Manu Krishnan T V&lt;br /&gt;
** ID: 0x51C954405D432381 - Fayad Fami (fayad)&lt;br /&gt;
** ID: 0x863D4DF2ED9C28EF - Abhijith PA&lt;br /&gt;
** ID: 0x6EF48CCD865A1FFC - Syam G Krishnan (sgk)&lt;br /&gt;
** ID: 0xFD49D0BC6FEAECDA - Sagar Ippalpalli&lt;br /&gt;
** ID: 0x92FDAB42A95FF20C - Pirate Bady (piratesin)&lt;br /&gt;
** ID: 0x0B1955F40C691CCE - Kannan&lt;br /&gt;
** ID: 0x32FF6C6F5B7AE248 - Akhil Varkey&lt;br /&gt;
** ID: 0xFBB7061C27CB70C1 - Ranjith Siji&lt;br /&gt;
** ID: 0xEAAFE4A8F39DE34F - Kiran S Kunjumon (hacksk)&lt;br /&gt;
* It&#039;s recommended to setup [http://www.vim.org/scripts/script.php?script_id=3645 Vim GnuPG Plugin] for transparent editing. Those who are new to GPG can follow [https://www.madboa.com/geek/gpg-quickstart/ this guide].&lt;br /&gt;
&lt;br /&gt;
=== Server Access ===&lt;br /&gt;
Maintained in a private git repo at https://git.fosscommunity.in/community/access&lt;br /&gt;
&lt;br /&gt;
= Configuration and Maintenance =&lt;br /&gt;
&lt;br /&gt;
Boot into rescue system using https://docs.hetzner.com/robot/dedicated-server/troubleshooting/hetzner-rescue-system&lt;br /&gt;
&lt;br /&gt;
== Disk Partitioning ==&lt;br /&gt;
* RAID 1 setup on 2x2TB HDDs (&amp;lt;code&amp;gt;sda&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;sdb&amp;lt;/code&amp;gt;).&lt;br /&gt;
 mdadm --verbose --create /dev/mdX --level=mirror --raid-devices=2 /dev/sdaY /dev/sdbY&lt;br /&gt;
* Separate partitions for swap (&amp;lt;code&amp;gt;md0&amp;lt;/code&amp;gt; - 16GB), boot (&amp;lt;code&amp;gt;md1&amp;lt;/code&amp;gt; - 512MB) and root (&amp;lt;code&amp;gt;md2&amp;lt;/code&amp;gt; - 50GB).&lt;br /&gt;
* LVM on Luks for separate encrypted data partitions for database, static files and logs.&lt;br /&gt;
 # Setup LUKS (make sure &amp;lt;code&amp;gt;lvm2&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;udev&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;cryptsetup&amp;lt;/code&amp;gt; packages are installed).&lt;br /&gt;
 cryptsetup luksFormat /dev/mdX&lt;br /&gt;
 # Give disk encryption password as specified in the [[#Server_Access|access repo]]&lt;br /&gt;
 cryptsetup luksOpen /dev/mdX poddery&lt;br /&gt;
 &lt;br /&gt;
 # LVM Setup&lt;br /&gt;
 # Create physical volume named &amp;lt;code&amp;gt;poddery&amp;lt;/code&amp;gt;&lt;br /&gt;
 pvcreate /dev/mapper/poddery&lt;br /&gt;
 # Create volume group named &amp;lt;code&amp;gt;data&amp;lt;/code&amp;gt;&lt;br /&gt;
 vgcreate data /dev/mapper/poddery&lt;br /&gt;
 # Create logical volumes named &amp;lt;code&amp;gt;log&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;db&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;static&amp;lt;/code&amp;gt;&lt;br /&gt;
 lvcreate -n log /dev/data -L 50G&lt;br /&gt;
 lvcreate -n db /dev/data -L 500G&lt;br /&gt;
 # Assign remaining free space for static files&lt;br /&gt;
 lvcreate -n static /dev/data -l 100%FREE &lt;br /&gt;
 &lt;br /&gt;
 # Setup filesystem on the logical volumes&lt;br /&gt;
 mkfs.ext4 /dev/data/log&lt;br /&gt;
 mkfs.ext4 /dev/data/db&lt;br /&gt;
 mkfs.ext4 /dev/data/static&lt;br /&gt;
 &lt;br /&gt;
 # Create directories for mounting the encrypted partitions&lt;br /&gt;
 mkdir /var/lib/db /var/lib/static /var/log/poddery&lt;br /&gt;
 &lt;br /&gt;
 # Manually mount encrypted partitions. This is needed on each reboot as Hetzner doesn&#039;t provide a web console so that we can&#039;t decrypt the partitions during booting.&lt;br /&gt;
 mount /dev/data/db /var/lib/db&lt;br /&gt;
 mount /dev/data/static /var/lib/static&lt;br /&gt;
 mount /dev/data/log /var/log/poddery&lt;br /&gt;
&lt;br /&gt;
== Hardening checklist ==&lt;br /&gt;
* SSH password based login disabled (allow only key based logins)&lt;br /&gt;
* SSH login disabled for root user (use a normal user with sudo)&lt;br /&gt;
 # Check for the following settings in /etc/ssh/sshd_config:&lt;br /&gt;
 ...&lt;br /&gt;
 PermitRootLogin no&lt;br /&gt;
 ...&lt;br /&gt;
 PasswordAuthentication no&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;ufw&amp;lt;/code&amp;gt; firewall enabled with only the ports that needs to be opened ([https://fxdata.cloud/tutorials/set-up-a-firewall-with-ufw-on-ubuntu-16-04 ufw tutorial]):&lt;br /&gt;
 ufw default deny incoming&lt;br /&gt;
 ufw default allow outgoing&lt;br /&gt;
 ufw allow ssh&lt;br /&gt;
 ufw allow http/tcp&lt;br /&gt;
 ufw allow https/tcp&lt;br /&gt;
 ufw allow Turnserver&lt;br /&gt;
 ufw allow XMPP&lt;br /&gt;
 ufw allow 8448&lt;br /&gt;
&lt;br /&gt;
 ufw enable&lt;br /&gt;
 &lt;br /&gt;
 # Verify everything is setup properly&lt;br /&gt;
 ufw status&lt;br /&gt;
 &lt;br /&gt;
 # Enable ufw logging with default mode low&lt;br /&gt;
 ufw logging on&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;fail2ban&amp;lt;/code&amp;gt; configured against brute force attacks:&lt;br /&gt;
 # Check for the following line &amp;lt;code&amp;gt;/etc/ssh/sshd_config&amp;lt;/code&amp;gt;&lt;br /&gt;
 ...&lt;br /&gt;
 LogLevel VERBOSE&lt;br /&gt;
 ...&lt;br /&gt;
 &lt;br /&gt;
 # Restart SSH and enable fail2ban&lt;br /&gt;
 systemctl restart ssh&lt;br /&gt;
 systemctl enable fail2ban&lt;br /&gt;
 systemctl start fail2ban&lt;br /&gt;
 &lt;br /&gt;
 # To unban an IP, first check &amp;lt;code&amp;gt;/var/log/fail2ban.log&amp;lt;/code&amp;gt; to get the banned IP and then run the following&lt;br /&gt;
 # Here &amp;lt;code&amp;gt;sshd&amp;lt;/code&amp;gt; is the defaut jail name, change it if you are using a different jail&lt;br /&gt;
 fail2ban-client set sshd unbanip &amp;lt;banned_ip&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Diaspora ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;diaspora-installer&amp;lt;/code&amp;gt; from Debian Buster contrib:&lt;br /&gt;
 apt install diaspora-installer&lt;br /&gt;
&lt;br /&gt;
* Move MySQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop mysql&lt;br /&gt;
 systemctl disable mysql&lt;br /&gt;
 mv /var/lib/mysql /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/mysql /var/lib/&lt;br /&gt;
 systemctl start mysql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/diaspora&lt;br /&gt;
 mv /usr/share/diaspora/public/uploads /var/lib/static/diaspora&lt;br /&gt;
 ln -s /var/lib/static/diaspora/uploads /usr/share/diaspora/public/&lt;br /&gt;
 chown -R diaspora: /var/lib/static/diaspora&lt;br /&gt;
&lt;br /&gt;
* Modify configuration files at &amp;lt;code&amp;gt;/etc/diaspora&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;/etc/diaspora.conf&amp;lt;/code&amp;gt; as needed (backup of the current configuration files are available in the [[#Server_Access|access repo]]).&lt;br /&gt;
* Homepage configuration:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;git&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;acl&amp;lt;/code&amp;gt; packages are installed&lt;br /&gt;
 # Grant &amp;lt;code&amp;gt;rwx&amp;lt;/code&amp;gt; permissions for the ssh user to &amp;lt;code&amp;gt;/usr/share/diaspora/public&amp;lt;/code&amp;gt;&lt;br /&gt;
 setfacl -m &amp;quot;u:&amp;lt;ssh_user&amp;gt;:rwx&amp;quot; /usr/share/diaspora/public&lt;br /&gt;
 &lt;br /&gt;
 # Clone poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public&lt;br /&gt;
 git clone https://git.fosscommunity.in/community/poddery.com.git&lt;br /&gt;
 cd poddery.com &amp;amp;&amp;amp; mv * .[^.]* .. #Give yes for all files when prompted&lt;br /&gt;
 cd .. &amp;amp;&amp;amp; rmdir poddery.com&lt;br /&gt;
&lt;br /&gt;
* [https://save.poddery.com Save Poddery] repo is maintained as a sub module in poddery.com repo. See this [https://chrisjean.com/git-submodules-adding-using-removing-and-updating/ tutorial] for working with git submodules. &lt;br /&gt;
 # Clone save.poddery.com repo&lt;br /&gt;
 cd /usr/share/diaspora/public/save&lt;br /&gt;
 git submodule init&lt;br /&gt;
 git submodule update&lt;br /&gt;
&lt;br /&gt;
== Matrix ==&lt;br /&gt;
* See the [https://github.com/matrix-org/synapse/blob/master/INSTALL.md official installation guide] of Synapse for installing from source.&lt;br /&gt;
* Nginx is used as reverse proxy to send requests that has &amp;lt;code&amp;gt;/_matrix/*&amp;lt;/code&amp;gt; in URL to Synapse on port &amp;lt;code&amp;gt;8008&amp;lt;/code&amp;gt;. This is configured in &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Shamil&#039;s [https://git.fosscommunity.in/necessary129/synapse-diaspora-auth Synapse Diaspora Auth] script is used to authenticate Synapse with Diaspora database.&lt;br /&gt;
* Move PostgreSQL data to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/db&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/db&amp;lt;/code&amp;gt;&lt;br /&gt;
 systemctl stop postgresql&lt;br /&gt;
 systemctl disable postgresql&lt;br /&gt;
 mv /var/lib/postgres /var/lib/db/&lt;br /&gt;
 ln -s /var/lib/db/postgres /var/lib/&lt;br /&gt;
 systemctl start postgresql&lt;br /&gt;
&lt;br /&gt;
* Move static files to encrypted partition:&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;/dev/data/static&amp;lt;/code&amp;gt; is mounted to &amp;lt;code&amp;gt;/var/lib/static&amp;lt;/code&amp;gt;&lt;br /&gt;
 mkdir /var/lib/static/synapse&lt;br /&gt;
 mv /var/lib/matrix-synapse/uploads /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/uploads /var/lib/matrix-synapse/&lt;br /&gt;
 mv /var/lib/matrix-synapse/media /var/lib/static/synapse/&lt;br /&gt;
 ln -s /var/lib/static/synapse/media /var/lib/matrix-synapse/&lt;br /&gt;
 chown -R matrix-synapse: /var/lib/static/synapse&lt;br /&gt;
&lt;br /&gt;
* Install identity server &amp;lt;code&amp;gt;mxisd&amp;lt;/code&amp;gt; (&amp;lt;code&amp;gt;deb&amp;lt;/code&amp;gt; package available [https://github.com/kamax-matrix/mxisd/blob/master/docs/install/debian.md here])&lt;br /&gt;
&lt;br /&gt;
=== Workers ===&lt;br /&gt;
* For scalability, Poddery is running [https://github.com/matrix-org/synapse/blob/master/docs/workers.md workers]. Currently all workers specified in that page, expect &amp;lt;code&amp;gt;synapse.app.appservice&amp;lt;/code&amp;gt; is running on poddery.com&lt;br /&gt;
* A new service [https://gist.github.com/necessary129/5dfbb140e4727496b0ad2bf801c10fdc &amp;lt;code&amp;gt;matrix-synapse@.service&amp;lt;/code&amp;gt;] is installed for the workers (Save the &amp;lt;code&amp;gt;synape_worker&amp;lt;/code&amp;gt; file somewhere like &amp;lt;code&amp;gt;/usr/local/bin/&amp;lt;/code&amp;gt; or something).&lt;br /&gt;
* The worker config can be found at &amp;lt;code&amp;gt;/etc/matrix-synapse/workers&amp;lt;/code&amp;gt;&lt;br /&gt;
* Synapse needs to be put under a reverse proxy see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/matrix&amp;lt;/code&amp;gt;. A lot of &amp;lt;code&amp;gt;/_matrix/&amp;lt;/code&amp;gt; urls needs to be overridden too see &amp;lt;code&amp;gt;/etc/nginx/sites-enabled/diaspora&amp;lt;/code&amp;gt;&lt;br /&gt;
* These lines must be added to &amp;lt;code&amp;gt;homeserver.yaml&amp;lt;/code&amp;gt; as we are running &amp;lt;code&amp;gt;media_repository&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;federation_sender&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;pusher&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;user_dir&amp;lt;/code&amp;gt; workers respectively:&lt;br /&gt;
  enable_media_repo: False&lt;br /&gt;
  send_federation: False&lt;br /&gt;
  start_pushers: False&lt;br /&gt;
  update_user_directory: false&lt;br /&gt;
&lt;br /&gt;
* These services must be enabled:&lt;br /&gt;
&lt;br /&gt;
 matrix-synapse@synchrotron.service matrix-synapse@federation_reader.service matrix-synapse@event_creator.service matrix-synapse@federation_sender.service matrix-synapse@pusher.service matrix-synapse@user_dir.service matrix-synapse@media_repository.service matrix-synapse@frontend_proxy.service matrix-synapse@client_reader.service matrix-synapse@synchrotron_2.service&lt;br /&gt;
&lt;br /&gt;
To load balance between the 2 synchrotrons, We are running [https://github.com/Sorunome/matrix-synchrotron-balancer matrix-synchrotron-balancer]. It has a systemd file at &amp;lt;code&amp;gt;/etc/systemd/system/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;. The files are in &amp;lt;code&amp;gt;/opt/matrix-synchrotron-balancer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Synapse Updation ===&lt;br /&gt;
* First check [https://matrix-org.github.io/synapse/latest/upgrade synapse//latest/upgrade] to see if anything extra needs to be done. Then, just run &amp;lt;code&amp;gt;/root/upgrade-synapse&amp;lt;/code&amp;gt;&lt;br /&gt;
* Current version of synapse can be found from https://poddery.com/_matrix/federation/v1/version&lt;br /&gt;
&lt;br /&gt;
=== Riot-web Updation === &lt;br /&gt;
* Just run the following (make sure to replace &amp;lt;code&amp;gt;&amp;lt;version&amp;gt;&amp;lt;/code&amp;gt; with a proper version number like &amp;lt;code&amp;gt;v1.0.0&amp;lt;/code&amp;gt;):&lt;br /&gt;
 /var/www/get-riot &amp;lt;version&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Chat/XMPP ==&lt;br /&gt;
* Steps for setting up Prosody is given at https://wiki.debian.org/Diaspora/XMPP&lt;br /&gt;
 # Follow steps 1 to 6 from https://wiki.debian.org/Diaspora/XMPP and then run the following:&lt;br /&gt;
 mysql -u root -p # Enter password from the access repo&lt;br /&gt;
 &lt;br /&gt;
 CREATE USER &#039;prosody&#039;@&#039;localhost&#039; IDENTIFIED BY &#039;&amp;lt;passwd_in_repo&amp;gt;&#039;;&lt;br /&gt;
 GRANT ALL PRIVILEGES ON diaspora_production.* TO &#039;prosody&#039;@&#039;localhost&#039;;&lt;br /&gt;
 FLUSH PRIVILEGES;&lt;br /&gt;
 &lt;br /&gt;
 systemctl restart prosody&lt;br /&gt;
&lt;br /&gt;
* Install plugins&lt;br /&gt;
 # Make sure &amp;lt;code&amp;gt;mercurial&amp;lt;/code&amp;gt; is installed&lt;br /&gt;
 cd /etc &amp;amp;&amp;amp; hg clone https://hg.prosody.im/prosody-modules/ prosody-modules&lt;br /&gt;
&lt;br /&gt;
=== Set Nginx Conf for BOSH URLS ===&lt;br /&gt;
* Add the following in &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration file to enable the BOSH URL to make JSXC Working:&lt;br /&gt;
 upstream chat_cluster {&lt;br /&gt;
   server localhost:5280;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
 location /http-bind {&lt;br /&gt;
   proxy_set_header X-Real-IP $remote_addr;&lt;br /&gt;
   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;&lt;br /&gt;
   proxy_set_header Host $http_host;&lt;br /&gt;
   proxy_set_header X-Forwarded-Proto https;&lt;br /&gt;
   proxy_redirect off;&lt;br /&gt;
   proxy_connect_timeout 5;&lt;br /&gt;
   proxy_buffering       off;&lt;br /&gt;
   proxy_read_timeout    70;&lt;br /&gt;
   keepalive_timeout     70;&lt;br /&gt;
   send_timeout          70;&lt;br /&gt;
   client_max_body_size 4M;&lt;br /&gt;
   client_body_buffer_size 128K;&lt;br /&gt;
   proxy_pass http://chat_cluster;&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.diasporafoundation.org/Integration/Chat#Nginx See here] for more details on &amp;lt;code&amp;gt;nginx&amp;lt;/code&amp;gt; configuration. Alternatively, &amp;lt;code&amp;gt;apache&amp;lt;/code&amp;gt; settings can be found [https://github.com/jsxc/jsxc/wiki/Prepare-apache here].&lt;br /&gt;
&lt;br /&gt;
== TLS ==&lt;br /&gt;
* Install &amp;lt;code&amp;gt;letsencrypt&amp;lt;/code&amp;gt;.&lt;br /&gt;
* Ensure proper permissions are set for &amp;lt;code&amp;gt;/etc/letsencrypt&amp;lt;/code&amp;gt; and its contents.&lt;br /&gt;
 chown -R root:ssl-cert /etc/letsencrypt&lt;br /&gt;
 chmod g+r -R /etc/letsencrypt&lt;br /&gt;
 chmod g+x /etc/letsencrypt/{archive,live}&lt;br /&gt;
* Generate certificates. For more details see https://certbot.eff.org.&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;diaspora&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/diaspora/ssl&lt;br /&gt;
 &#039;&#039;total 0&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 47 Apr  2 22:47 poddery.com-bundle.pem -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 45 Apr  2 22:48 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/diaspora/ssl/poddery.com-bundle.pem&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/diaspora/ssl/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Make sure the certificates used by &amp;lt;code&amp;gt;prosody&amp;lt;/code&amp;gt; are symbolic links to letsencrypt default location:&lt;br /&gt;
 ls -l /etc/prosody/certs/&lt;br /&gt;
 &#039;&#039;total 0&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 40 Mar 28 01:16 poddery.com.crt -&amp;gt; /etc/letsencrypt/live/poddery.com/fullchain.pem&#039;&#039;&lt;br /&gt;
 &#039;&#039;lrwxrwxrwx 1 root root 33 Mar 28 01:16 poddery.com.key -&amp;gt; /etc/letsencrypt/live/poddery.com/privkey.pem&#039;&#039;&lt;br /&gt;
 &lt;br /&gt;
 # If you don&#039;t get the above output, then run the following:&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/fullchain.pem /etc/prosody/certs/poddery.com.crt&lt;br /&gt;
 cp -L /etc/letsencrypt/live/poddery.com/privkey.pem /etc/prosody/certs/poddery.com.key&lt;br /&gt;
&lt;br /&gt;
* Note- letsencrypt executable used below is actually a symlik to /usr/bin/certbot&lt;br /&gt;
* Cron jobs:&lt;br /&gt;
 crontab -e&lt;br /&gt;
 &#039;&#039;30 2 * * 1 letsencrypt renew  &amp;gt;&amp;gt; /var/log/le-renew.log&#039;&#039;&lt;br /&gt;
 &#039;&#039;32 2 * * 1 /etc/init.d/nginx reload&#039;&#039;&lt;br /&gt;
 &#039;&#039;34 2 * * 1 /etc/init.d/prosody reload&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* Manually updating TLS certificate:&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos -w /usr/share/diaspora/public  -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save -d save.poddery.com -w /var/www/riot -d chat.poddery.com&lt;br /&gt;
* To include an additional subdomain such as fund.poddery.com use with --expand parameter as shown below&lt;br /&gt;
 letsencrypt certonly --webroot --agree-tos --expand -w /usr/share/diaspora/public -d poddery.com -d www.poddery.com -d test.poddery.com -d groups.poddery.com -d fund.poddery.com -w /usr/share/diaspora/public/save/ -d save.poddery.com -w /var/www/riot/ -d chat.poddery.com&lt;br /&gt;
&lt;br /&gt;
==Backup==&lt;br /&gt;
&lt;br /&gt;
Backup server is provided by Manu (KVM virtual machine with 180 GB storage and 1 GB ram ). &lt;br /&gt;
&lt;br /&gt;
Debian Stetch was upgraded Debian Buster before database relication of synapse database. &lt;br /&gt;
&lt;br /&gt;
Documentation: https://www.percona.com/blog/2018/09/07/setting-up-streaming-replication-postgresql/&lt;br /&gt;
&lt;br /&gt;
Currently postgres database for matrix-synapse is backed up.&lt;br /&gt;
&lt;br /&gt;
===Before Replication (specific to poddery.com)===&lt;br /&gt;
&lt;br /&gt;
Setup tinc vpn in the backup server&lt;br /&gt;
&lt;br /&gt;
 # apt install tinc&lt;br /&gt;
&lt;br /&gt;
Configure tinc by creating tinc.conf and host podderybackup under label fsci.&lt;br /&gt;
Add tinc-up and tinc-down scripts&lt;br /&gt;
Copy poddery host config to backup server and podderybackup host config to poddery.com server.&lt;br /&gt;
&lt;br /&gt;
Reload tinc vpn service at both poddery.com and backup servers&lt;br /&gt;
&lt;br /&gt;
 # systemctl reload tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
Enable tinc@fsci systemd service for autostart&lt;br /&gt;
&lt;br /&gt;
 # systemctl enable tinc@fsci.service&lt;br /&gt;
&lt;br /&gt;
The synapse database was also pruned to reduce the size before replication by following this guide - https://levans.fr/shrink-synapse-database.html&lt;br /&gt;
If you want to follow this guide, make sure matrix synapse server is updated to version 1.13 atleast since it introduces the Rooms API mentioned the guide.&lt;br /&gt;
Changes done to steps in the guide.&lt;br /&gt;
&lt;br /&gt;
  # jq &#039;.rooms[] | select(.joined_local_members == 0) | .room_id&#039; &amp;lt; roomlist.json | sed -e &#039;s/&amp;quot;//g&#039; &amp;gt; to_purge.txt&lt;br /&gt;
&lt;br /&gt;
The room list obtained this way can, be looped to pass the room names as variables to the purge api. &lt;br /&gt;
&lt;br /&gt;
 # set +H // if you are using bash to avoid &#039;!&#039; in the roomname triggering the history substitution.&lt;br /&gt;
 # for room_id in $(cat to_purge.txt); do curl --header &amp;quot;Authorization: Bearer &amp;lt;your access token&amp;gt;&amp;quot; \&lt;br /&gt;
    -X POST -H &amp;quot;Content-Type: application/json&amp;quot; -d &amp;quot;{ \&amp;quot;room_id\&amp;quot;: \&amp;quot;$room_id\&amp;quot; }&amp;quot; \&lt;br /&gt;
    &#039;https://127.0.0.1:8008/_synapse/admin/v1/purge_room&#039;; done;&lt;br /&gt;
&lt;br /&gt;
We also did not remove old history of large rooms.&lt;br /&gt;
&lt;br /&gt;
===Step 1: Postgresql (for synapse) Primary configuration===&lt;br /&gt;
&lt;br /&gt;
Create postgresql user for replication.&lt;br /&gt;
&lt;br /&gt;
 $ psql -c &amp;quot;CREATE USER replication REPLICATION LOGIN CONNECTION LIMIT 1 ENCRYPTED PASSWORD &#039;yourpassword&#039;;&amp;quot;&lt;br /&gt;
The password is in the access repo if you need it later.&lt;br /&gt;
&lt;br /&gt;
Allow standby to connect to primary using the user just created.&lt;br /&gt;
&lt;br /&gt;
 $ cd /etc/postgresql/11/main&lt;br /&gt;
&lt;br /&gt;
 $ nano pg_hba.conf&lt;br /&gt;
&lt;br /&gt;
Add below line to allow replication user to get access to the server&lt;br /&gt;
&lt;br /&gt;
 host    replication     replication     172.16.0.3/32   md5&lt;br /&gt;
&lt;br /&gt;
Next , open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 listen_addresses = &#039;localhost,172.16.0.2&#039;&lt;br /&gt;
 port=5432&lt;br /&gt;
 wal_level = replica&lt;br /&gt;
 max_wal_senders = 1&lt;br /&gt;
 wal_keep_segments = 64&lt;br /&gt;
 archive_mode = on&lt;br /&gt;
 archive_command = &#039;cd .&#039;&lt;br /&gt;
&lt;br /&gt;
You need to restart since postgresql.conf was edited and parameters changed,&lt;br /&gt;
&lt;br /&gt;
 # systemctl restart postgresql&lt;br /&gt;
&lt;br /&gt;
===Step 2: Postgresql (for synapse) Standby configuration ===&lt;br /&gt;
&lt;br /&gt;
Install postgresql &lt;br /&gt;
&lt;br /&gt;
 # apt install postgresql&lt;br /&gt;
&lt;br /&gt;
Check postgresql server is running&lt;br /&gt;
&lt;br /&gt;
 # su postgres -c psql&lt;br /&gt;
&lt;br /&gt;
Make sure en_US.UTF-8 locale is available&lt;br /&gt;
&lt;br /&gt;
 # dpkg-reconfigure locales&lt;br /&gt;
&lt;br /&gt;
Stop postgresql before changing any configuration&lt;br /&gt;
&lt;br /&gt;
 #systemctl stop postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
Switch to postgres user&lt;br /&gt;
&lt;br /&gt;
 # su - postgres&lt;br /&gt;
 $ cd /etc/postgresql/11/&lt;br /&gt;
&lt;br /&gt;
Copy data from master and create recovery.conf&lt;br /&gt;
&lt;br /&gt;
 $ pg_basebackup -h git.fosscommunity.in -D /var/lib/postgresql/11/main/ -P -U rep --wal-method=fetch  -R&lt;br /&gt;
&lt;br /&gt;
Open the postgres configuration file&lt;br /&gt;
&lt;br /&gt;
 $ nano postgresql.conf&lt;br /&gt;
&lt;br /&gt;
Set the following configuration options in the postgresql.conf file&lt;br /&gt;
&lt;br /&gt;
 max_connections = 500 // This option and the one below are set to be same as in postgresql.conf at primary or the service won&#039;t start.&lt;br /&gt;
 max_worker_processes = 16&lt;br /&gt;
 host_standby = on // The above pg_basebackup command should set it. If it&#039;s not manually turn it to on.&lt;br /&gt;
&lt;br /&gt;
Start the stopped postgresql service&lt;br /&gt;
&lt;br /&gt;
 # systemctl start postgresql@11-main&lt;br /&gt;
&lt;br /&gt;
===Postgresql (for synapse) Replication Status===&lt;br /&gt;
&lt;br /&gt;
On Primary,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep sender&lt;br /&gt;
 $ psql -c &amp;quot;select * from pg_stat_activity where usename=&#039;rep&#039;;&amp;quot;&lt;br /&gt;
&lt;br /&gt;
On Standby,&lt;br /&gt;
&lt;br /&gt;
 $ ps -ef | grep receiver&lt;br /&gt;
&lt;br /&gt;
===Backup steps on 7th Jan 2025===&lt;br /&gt;
====Matrix-synapse====&lt;br /&gt;
For synapse, the following files were backed up:&lt;br /&gt;
- Dump of postgresql using `pg_dump`&lt;br /&gt;
- `/etc/matrix-synapse`&lt;br /&gt;
- `/var/lib/static/synapse/media`&lt;br /&gt;
&lt;br /&gt;
In order to access the poddery server from the backup server (with your public ssh keys added to both the servers in `~/.ssh/authorized-keys`), run the following command in your local system:&lt;br /&gt;
&lt;br /&gt;
`eval &amp;quot;$(ssh-agent -s)&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
followed by&lt;br /&gt;
&lt;br /&gt;
`ssh user@server -o &amp;quot;ForwardAgent yes&amp;quot; -o &amp;quot;AddKeysToAgent yes&amp;quot;`&lt;br /&gt;
on the local system.&lt;br /&gt;
&lt;br /&gt;
The dump was taken using the command from the [https://element-hq.github.io/synapse/latest/usage/administration/backups.html#quick-and-easy-database-backup-and-restore official docs]:&lt;br /&gt;
&lt;br /&gt;
`ssh user@poddery-server &#039;sudo -u postgres pg_dump -Fc --exclude-table-data e2e_one_time_keys_json synapse&#039; &amp;gt; poddery-backups/matrix-synapse/synapse-2025-01-07.dump`&lt;br /&gt;
&lt;br /&gt;
====Prosody====&lt;br /&gt;
The following were backed up for  prosody:&lt;br /&gt;
- Dump of the database using `mysqldump` &lt;br /&gt;
- `/var/lib/prosody` for media files&lt;br /&gt;
- `/etc/prosody` for config files&lt;br /&gt;
&lt;br /&gt;
For taking the dump, the following was run from the backup-server&lt;br /&gt;
`ssh user@poddery-server &#039;mysqldump -u prosody --password=&amp;quot;$(cat &amp;lt;path/to/password-file&amp;gt;)&amp;quot; prosody | gzip&#039; &amp;gt; backups/prosody-backup-2024-10-27.sql.gz`&lt;br /&gt;
&lt;br /&gt;
= Troubleshooting =&lt;br /&gt;
== Allow XMPP login even if diaspora account is closed ==&lt;br /&gt;
Diaspora has a [https://github.com/diaspora/diaspora/blob/develop/Changelog.md#new-maintenance-feature-to-automatically-expire-inactive-accounts default setting] to close accounts that have been inactive for 2 years. At the time of writing, there seems [https://github.com/diaspora/diaspora/issues/5358#issuecomment-371921462 no way] to reopen a closed account. This also means that if your account is closed, you will no longer be able to login to the associated XMPP service as well. Here we discuss a workaround to get access back to the XMPP account.&lt;br /&gt;
&lt;br /&gt;
The prosody module [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua mod_auth_diaspora] is used for diaspora-based XMPP auth. It checks if &amp;lt;code&amp;gt;locked_at&amp;lt;/code&amp;gt; value in the &amp;lt;code&amp;gt;users&amp;lt;/code&amp;gt; table of diaspora db is &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L89 here] and [https://gist.github.com/jhass/948e8e8d87b9143f97ad#file-mod_auth_diaspora-lua-L98 here]. If your account is locked, it will have the &amp;lt;code&amp;gt;datetime&amp;lt;/code&amp;gt; value that represents the date and time at which your account is locked. Setting it back to &amp;lt;code&amp;gt;null&amp;lt;/code&amp;gt; will let you use your XMPP account again.&lt;br /&gt;
&lt;br /&gt;
 -- Replace &amp;lt;username&amp;gt; with actual username of the locked account&lt;br /&gt;
 UPDATE users SET locked_at=NULL WHERE username=&#039;&amp;lt;username&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
NOTE: Matrix account won&#039;t be affected even if the associated diaspora account is closed because it uses a [https://pypi.org/project/synapse-diaspora-auth/ custom auth module] which works differently.&lt;br /&gt;
&lt;br /&gt;
= History =&lt;br /&gt;
* [[Poddery/Archive|See here]] for the archive of Poddery wiki page before the migration to Hetzner.&lt;br /&gt;
&lt;br /&gt;
[[Category:Services]]&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=User:Ravi&amp;diff=11027</id>
		<title>User:Ravi</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=User:Ravi&amp;diff=11027"/>
		<updated>2022-01-30T22:11:07Z</updated>

		<summary type="html">&lt;p&gt;Ravi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Name: Ravi&lt;br /&gt;
&lt;br /&gt;
Webpage: https://ravidwivedi.in&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=User:Ravi&amp;diff=11026</id>
		<title>User:Ravi</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=User:Ravi&amp;diff=11026"/>
		<updated>2022-01-30T22:10:46Z</updated>

		<summary type="html">&lt;p&gt;Ravi: Created page with &amp;quot;Name: Ravi Webpage: https://ravidwivedi.in&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Name: Ravi&lt;br /&gt;
Webpage: https://ravidwivedi.in&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Learn_Debian_Packaging&amp;diff=11025</id>
		<title>Learn Debian Packaging</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Learn_Debian_Packaging&amp;diff=11025"/>
		<updated>2022-01-30T22:06:58Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Level 0: Basics of release process and setup a development environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We are guiding some learners of [https://camp.fsf.org.in Free Software Camp] to learn Debian Packaging and this page will be used to track the progress of the tasks.&lt;br /&gt;
&lt;br /&gt;
== Level 0: Basics of release process and setup a development environment ==&lt;br /&gt;
* [http://www.queryadmin.com/2203/how-to-install-a-deb-file-on-debian-linux-via-command-line/ How to Install a .Deb File via Command-Line]&lt;br /&gt;
* [https://debian-handbook.info/browse/stable/sect.release-lifecycle.html Lifecycle of a Release]&lt;br /&gt;
* [https://raphaelhertzog.com/2010/10/18/understanding-debians-release-process/ Understanding Debian’s release process]&lt;br /&gt;
* [https://backports.debian.org/Instructions/ How to install packages from stable-backports]&lt;br /&gt;
* [https://wiki.debian.org/Packaging/Pre-Requisites Different options for setting up a Debian Sid environment]&lt;br /&gt;
* [https://wiki.debian.org/BuildingTutorial Building existing packages from source]&lt;br /&gt;
&lt;br /&gt;
By this time you should be familiar with &lt;br /&gt;
# apt source/dget, &lt;br /&gt;
# dpkg-source -x, &lt;br /&gt;
# dpkg-buildpackage/debuild, &lt;br /&gt;
# apt build-dep, &lt;br /&gt;
# apt-source -b &lt;br /&gt;
commands to rebuild an existing debian package from source.&lt;br /&gt;
&lt;br /&gt;
== Level 1: Learn basics of Packaging ==&lt;br /&gt;
&lt;br /&gt;
Understand the basic concepts using debmake/dh_make (getting source tarballs, creating source package, building the binary package, making it lintian clean)&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.abrahamraji.in/simple-packaging-tutorial/ Abraham Raji&#039;s simple packaging tutorial]&lt;br /&gt;
* [https://wiki.debian.org/SimplePackagingTutorial Simple Packaging Tutorial on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
Once you understand the basic concepts, use npm2deb to automate some of those tasks like getting source tarball, a better debian directory template than the ones created by dh_make/debmake as npm2deb knows more details specific to node modules. You will still have to fix the remaining issues flagged by lintian.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/Javascript/Nodejs/Npm2Deb/Tutorial npm2deb Tutorial on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# creating lintian clean packages for simple modules and &lt;br /&gt;
# building it in a clean environment like sbuild. &lt;br /&gt;
# You should also know to import a dsc file to a git repo (gbp import-dsc --pristine-tar) and &lt;br /&gt;
# push your work to a public git hosting service like salsa.debian.org (git push -u --all --follow-tags)&lt;br /&gt;
&lt;br /&gt;
== Level 2: Update existing packages to new upstream minor or patch versions ==&lt;br /&gt;
Once you get a clear picture of packaging a simple module, we can move to the next stage of updating existing packages&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/UpdatingaPackagetoNewUpstreamVersion Update packages to new upstream version on Debian Wiki]&lt;br /&gt;
* [https://wiki.debian.org/UsingQuilt Using Quilt on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
# How to send RFS mails&lt;br /&gt;
# Using Quilt to modify upstream source if required&lt;br /&gt;
&lt;br /&gt;
== Level 3: Packaging more complicated modules ==&lt;br /&gt;
&lt;br /&gt;
Next step is packaging more complicated modules that will involve things like, modifying some upstream files, removing some files from source tarball, generating some files from source, getting the source tarball from a git commit etc.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/Javascript/Nodejs/Npm2Deb/AdvancedTutorial Advanced tutorial for more complicated modules]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# Creating patches with quilt&lt;br /&gt;
# Repacking orig.tar and exclude specific files&lt;br /&gt;
# Use pkg-js-tools options to build from source files&lt;br /&gt;
# Build packages with typescript sources&lt;br /&gt;
&lt;br /&gt;
== Level 4: Pick an unpackaged but useful module and upload to archive ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.fosscommunity.in/debian-ruby/TaskTracker/-/issues/175 List of node dependencies for gitlab]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# How to file ITP&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
	<entry>
		<id>https://wiki.fsci.in/index.php?title=Learn_Debian_Packaging&amp;diff=11024</id>
		<title>Learn Debian Packaging</title>
		<link rel="alternate" type="text/html" href="https://wiki.fsci.in/index.php?title=Learn_Debian_Packaging&amp;diff=11024"/>
		<updated>2022-01-30T14:55:47Z</updated>

		<summary type="html">&lt;p&gt;Ravi: /* Level 0: Basics of release process and setup a development environment */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;We are guiding some learners of [https://camp.fsf.org.in Free Software Camp] to learn Debian Packaging and this page will be used to track the progress of the tasks.&lt;br /&gt;
&lt;br /&gt;
== Level 0: Basics of release process and setup a development environment ==&lt;br /&gt;
* [http://www.queryadmin.com/2203/how-to-install-a-deb-file-on-debian-linux-via-command-line/ How to Install a .Deb File via Command-Line]&lt;br /&gt;
* [https://debian-handbook.info/browse/stable/sect.release-lifecycle.html/ Lifecycle of a Release]&lt;br /&gt;
* [https://raphaelhertzog.com/2010/10/18/understanding-debians-release-process/ Understanding Debian’s release process]&lt;br /&gt;
* [https://backports.debian.org/Instructions/ How to install packages from stable-backports]&lt;br /&gt;
* [https://wiki.debian.org/Packaging/Pre-Requisites Different options for setting up a Debian Sid environment]&lt;br /&gt;
* [https://wiki.debian.org/BuildingTutorial Building existing packages from source]&lt;br /&gt;
&lt;br /&gt;
By this time you should be familiar with &lt;br /&gt;
# apt source/dget, &lt;br /&gt;
# dpkg-source -x, &lt;br /&gt;
# dpkg-buildpackage/debuild, &lt;br /&gt;
# apt build-dep, &lt;br /&gt;
# apt-source -b &lt;br /&gt;
commands to rebuild an existing debian package from source.&lt;br /&gt;
&lt;br /&gt;
== Level 1: Learn basics of Packaging ==&lt;br /&gt;
&lt;br /&gt;
Understand the basic concepts using debmake/dh_make (getting source tarballs, creating source package, building the binary package, making it lintian clean)&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.abrahamraji.in/simple-packaging-tutorial/ Abraham Raji&#039;s simple packaging tutorial]&lt;br /&gt;
* [https://wiki.debian.org/SimplePackagingTutorial Simple Packaging Tutorial on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
Once you understand the basic concepts, use npm2deb to automate some of those tasks like getting source tarball, a better debian directory template than the ones created by dh_make/debmake as npm2deb knows more details specific to node modules. You will still have to fix the remaining issues flagged by lintian.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/Javascript/Nodejs/Npm2Deb/Tutorial npm2deb Tutorial on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# creating lintian clean packages for simple modules and &lt;br /&gt;
# building it in a clean environment like sbuild. &lt;br /&gt;
# You should also know to import a dsc file to a git repo (gbp import-dsc --pristine-tar) and &lt;br /&gt;
# push your work to a public git hosting service like salsa.debian.org (git push -u --all --follow-tags)&lt;br /&gt;
&lt;br /&gt;
== Level 2: Update existing packages to new upstream minor or patch versions ==&lt;br /&gt;
Once you get a clear picture of packaging a simple module, we can move to the next stage of updating existing packages&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/UpdatingaPackagetoNewUpstreamVersion Update packages to new upstream version on Debian Wiki]&lt;br /&gt;
* [https://wiki.debian.org/UsingQuilt Using Quilt on Debian Wiki]&lt;br /&gt;
&lt;br /&gt;
# How to send RFS mails&lt;br /&gt;
# Using Quilt to modify upstream source if required&lt;br /&gt;
&lt;br /&gt;
== Level 3: Packaging more complicated modules ==&lt;br /&gt;
&lt;br /&gt;
Next step is packaging more complicated modules that will involve things like, modifying some upstream files, removing some files from source tarball, generating some files from source, getting the source tarball from a git commit etc.&lt;br /&gt;
&lt;br /&gt;
* [https://wiki.debian.org/Javascript/Nodejs/Npm2Deb/AdvancedTutorial Advanced tutorial for more complicated modules]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# Creating patches with quilt&lt;br /&gt;
# Repacking orig.tar and exclude specific files&lt;br /&gt;
# Use pkg-js-tools options to build from source files&lt;br /&gt;
# Build packages with typescript sources&lt;br /&gt;
&lt;br /&gt;
== Level 4: Pick an unpackaged but useful module and upload to archive ==&lt;br /&gt;
&lt;br /&gt;
* [https://git.fosscommunity.in/debian-ruby/TaskTracker/-/issues/175 List of node dependencies for gitlab]&lt;br /&gt;
&lt;br /&gt;
By this time you should know,&lt;br /&gt;
# How to file ITP&lt;/div&gt;</summary>
		<author><name>Ravi</name></author>
	</entry>
</feed>