Make sure that all of the mandatory prerequisites have been met before progressing further.
Name | Source | Description |
---|---|---|
<CONTAINER_NAME> | User input | The name of the linux container that will be used to host the respective servers for SimpleX Chat. |
<IP_ADDRESS_INET_GW> | Linux VPS Admin Panel | The static and public IPv4 address of the Internet Gateway. |
<IP_ADDRESS_SERVER__VPN> | User input | The IPv4 address of the server on the Edge in the VPN, e.g. 10.5.5.2 . |
Going through all the steps in this guide shall take around 30 min. with decent Internet connection.
Run the following commands on your server on the Edge.
incus launch images:debian/bullseye/cloud <CONTAINER_NAME>
incus exec <CONTAINER_NAME> bash
ip link set dev eth0 mtu 1100
apt update
apt upgrade
apt install fish openssl wget
chsh -s /usr/bin/fish
useradd -m xftp
mkdir -p /var/opt/simplex-xftp
mkdir -p /etc/opt/simplex-xftp
mkdir -p /srv/xftp
chown xftp:xftp /var/opt/simplex-xftp
chown xftp:xftp /etc/opt/simplex-xftp
chown xftp:xftp /srv/xftp
mkdir -p /opt/xftp
chown -R xftp:xftp /opt/xftp
cd /opt/xftp
wget https://github.com/simplex-chat/simplexmq/releases/latest/download/xftp-server-ubuntu-20_04-x86-64
mv xftp-server-ubuntu-20_04-x86-64 xftp-server
chown xftp:xftp xftp-server
chmod +x xftp-server
vi /etc/systemd/system/xftp-server.service
Add the following content and save the file.
[Unit]
Description=XFTP server systemd service
[Service]
User=xftp
Group=xftp
Type=simple
ExecStart=/opt/xftp/xftp-server start +RTS -N -RTS
LimitNOFILE=65535
KillSignal=SIGINT
TimeoutStopSec=infinity
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
Make sure the IP address of the Internet Gateway <IP_ADDRESS_INET_GW> will be used by the xftp-server
.
sudo su xftp -c "./xftp-server init -l --ip <IP_ADDRESS_INET_GW> -q '100gb' -p /srv/xftp/"
At the end of the initialisation process a server address URL will be generated for you. Store it somewhere as you will need it to set up your app to use the XFTP server.
sudo su xftp -c "vim /etc/opt/simplex-xftp/file-server.ini"
To password-protect the xftp-server, amend the configuration under [AUTH] section and uncomment and assign value - a super secure password - to the create_password
property.
Don't forget to amend the value of the port
property to be 5443
.
systemctl enable xftp-server.service
systemctl start xftp-server.service
If the service has started successfully, exit the container.
On the Server on the Edge run the following command.
incus config device add <CONTAINER_NAME> port_5443 proxy connect="tcp:127.0.0.1:5443" listen="tcp:0.0.0.0:5443"
We need to set up TCP port forwarding on the Internet Gateway, so that the XFTP server would be able to serve requests.
ssh mycelium@<IP_ADDRESS_INET_GW>
sudo ufw allow 5443
sudo apt update && sudo apt install socat
vi /etc/systemd/system/xftp-bridge.service
Add the following content and save the file.
Do not forget to substitute <IP_ADDRESS_SERVER__VPN> with the actual IP address of the Server on the Edge.
# /etc/systemd/system/xftp-bridge.service
[Unit]
Description=A service managing the tcp port forwarding to a Simplex Chat XFTP server
[Service]
Type=simple
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=xftp-bridge
ExecStart=socat -d -d TCP-LISTEN:5443,forever,reuseaddr,fork TCP4:<IP_ADDRESS_SERVER__VPN>:5443
Restart=always
RuntimeMaxSec=900 # the service will be restarted every 15 min.
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable xftp-bridge.service
systemctl start xftp-bridge.service
You should be able to connect to your xftp server from the Simplex Chat app on your phone. Navigate to "Networks & servers" -> "XFTP servers" and use the XFTP server address that was generated during the initialisation of the server and the password that was used in
/etc/opt/simplex-xftp/file-server.ini
. Format: fingerprint:password@<IP_ADDRESS_SERVER__VPN>:5443
From here on every SimpleX Chat client app can use this server as a relay server for uploaded files.