Reposting in the new room because I actually use this a lot myself whenever I'm doing work with lotide. Thankfully, I think I managed to fix up the formatting this time. (I'll find out I'm wrong moments after hitting post!)
Introduction
Lotide is a link aggregator that allows federation using the ActivityPub protocol. Federation is a concept like email: You can communicate with people who are on other servers. The way lotide ends up working is you can host a community on your server and people on other servers can follow and contribute to your community, and you can follow and contribute to communities on other servers.
There's a number of different programs that allow federation, and together they're part of an ecosystem called the Fediverse. Besides lotide, there are twitter alternatives like Mastodon or Pleroma, Facebook alternatives like Friendica, Youtube alternatives like Peertube, messenger applications like Matrix, and many more. The Fediverse is a popular and growing ecosystem, with at least 10,000 servers and millions of users.
Federation is considered both a cure for big tech censorship, and a cure for the more questionable things on the Internet because it is decentralized. Different communities can run different servers, and each server can function with its own guidelines, so people who want a more curated experience can join servers with stricter moderation, and people who want freedom to say and hear a wider variety of things can join servers with less strict moderation or create their own server altogether.
Lotide consists of two different programs: Lotide itself is the back-end that handles storing, retrieving, and distributing posts throughout the federated network, and Hitide is the standard front-end that handles user interface.
Lotide and Hitide are both very lean programs. Lotide uses the Postgresql database on the back-end and is written in the rust programming language, and Hitide emits only pure HTML and CSS code and is also written in the rust programming language. As a result, the server runs comfortably on virtually any hardware that runs Linux, and the web page is standards compliant and can be accessed by virtually any web browser with some graceful degradation of the visual flair.
As with many programs, the standard method to run the program is to run it in a docker container. Personally, I've never had success with docker, and I prefer to run my programs directly. I was able to go through and figure out how to set up lotide, but I really regretted not having a simple step by step guide, so I've created this for the next person trying to create a lotide server.
Step 1: Gather information
[SMTP Username] - The username from your mail server
[SMTP password] - The password from your mail server
[SMTP Server] - The server name of your mail server
[SMTP From] - The email address emails from lotide will claim to be sent from
[lotide internal password] - A secure password you'll be using for the lotide internals
[lotide domain] - The domain you'll be hosting lotide on. This doesn't include https:// or http:// or any trailing slashes, it will just be for example lotide.com
Step 2: Install prerequisites
Log into your server, and run the following commands:
sudo su
apt install rustc
apt install openssl
apt install postgresql
apt install git
apt install pkg-config
apt install libssl-dev
Step 3: Set up database and user
Run the following commands to set up the database and local user.
adduser lotide
su - postgres
psql -U postgres
CREATE USER lotide WITH PASSWORD '[lotide internal password]';
CREATE DATABASE lotide;
GRANT ALL PRIVILEGES ON DATABASE lotide to lotide;
\q
exit
Step 4: Get and build lotide and hitide
Run the following commands to get the latest source code for lotide and hitide and build each. Be sure to change the square brackets to your own data!
cd /var
git clone https://git.sr.ht/~vpzom/lotide/
git clone https://git.sr.ht/~vpzom/hitide/
mkdir /var/lotide/media/
cd lotide
cargo build --release
systemctl start postgresql
export DATABASE_URL="postgresql://lotide:[lotide internal password]@localhost:5432/lotide"
export HOST_URL_ACTIVITYPUB="https://[lotide domain]/apub"
export HOST_URL_API="https://[lotide domain]/api"
export APUB_PROXY_REWRITES=true
export ALLOW_FORWARDED=true
export BACKEND_HOST="http://127.0.0.1:3333"
export MEDIA_LOCATION="/var/lotide/media/"
export SMTP_URL="smtps://[SMTP Username]:[SMTP password]@[SMTP Server]"
export SMTP_FROM="[SMTP From]"
target/release/lotide migrate setup
target/release/lotide migrate
create a file /var/lotide/target/release/lotide.sh with the following contents:
#!/bin/bash export DATABASE_URL="postgresql://lotide:[lotide internal password]@localhost:5432/lotide"
export HOST_URL_ACTIVITYPUB="https://[lotide domain]/apub"
export HOST_URL_API="https://[lotide domain]/api"
export APUB_PROXY_REWRITES=true
export ALLOW_FORWARDED=true
export BACKEND_HOST="http://127.0.0.1:3333"
export MEDIA_LOCATION="/var/lotide/media/"
export SMTP_URL="smtps://[SMTP Username]:[SMTP password]@[SMTP Server]"
export SMTP_FROM="[SMTP From]"
cd /var/lotide/target/release
./lotide
Next, run the following commands:
chmod og+rx /var/lotide/target/release/lotide.sh
cd ..
cd hitide
HOLD IT!!!
Before we continue, this is a good time to apply a theme to your instance!
Personally, I love hitide, but I think the default look is terrible. Black and white with serif fonts, it feels to like something out of 1994. We can do something about that and easily customize the look by modifying the file /var/hitide/res/main.css
Here's a neat trick that lets you figure out what you want to change. You can go to the flagship instance at https://narwhal.city/ using Google Chrome and right click on anything on the webpage, then click "inspect element". This will bring up a window that allows you to change the stylesheet for the currently displayed page, allowing you to preview what changes to your css file will look like. Then you can make the same changes to your main.css and after the next step those changes to CSS will be on your instance.
You can also make modifications to the name of the site by changing the /var/hitide/src/components/mod.rs file. Using your text editor, search for the text "lotide" and it should bring you directly to the spot in the code that displays the name of the site.
You can make changes later, but to do so you'll have to stop hitide, run the next line again, then restart hitide.
Ok, now that you've made any customizations you want, you can build with the following command:
cargo build --release
create a file /var/hitide/target/release/hitide.sh with the following contents:
#!/bin/bash export DATABASE_URL="postgresql://lotide:[lotide internal password]@localhost:5432/lotide"
export HOST_URL_ACTIVITYPUB="https://[lotide domain]/apub"
export HOST_URL_API="https://[lotide domain]/api"
export APUB_PROXY_REWRITES=true
export ALLOW_FORWARDED=true
export BACKEND_HOST="http://127.0.0.1:3333"
export MEDIA_LOCATION="/var/lotide/media/"
export SMTP_URL="smtps://[SMTP Username]:[SMTP password]@[SMTP Server]"
export SMTP_FROM="[SMTP From]"
cd /var/hitide/target/release
./hitide
Next, run the following commands:
chmod og+rx /var/hitide/target/release/hitide.sh
chown -R lotide:lotide /var/lotide
chown -R lotide:lotide /var/hitide
Step 5: Set up lotide and hitide to automatically run as services
Create the following file /etc/systemd/system/lotide.service with the following contents:
[Unit]
Description=Lotide
After=network.target
[Service]
Type=simple
User=lotide
Group=lotide
Restart=always
ExecStart=/var/lotide/target/release/lotide.sh
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
Create the following file /etc/systemd/system/hitide.service
[Unit]
Description=Hitide
After=network.target
[Service]
Type=simple
User=lotide
Group=lotide
Restart=always
ExecStart=/var/hitide/target/release/hitide.sh
Restart=on-failure
RestartSec=10
KillMode=process
[Install]
WantedBy=multi-user.target
Run the following commands to enable hitide and lotide to start at boot and to start them up immediately:
systemctl enable lotide
systemctl enable hitide
systemctl start lotide
systemctl start hitide
Step 6: Set up nginx to act as a reverse-proxy
apt install nginx
edit /etc/nginx/sites-available/default to include the following lines:
server { # simple reverse-proxy
listen 80;
access_log logs/domain2.access.log;
client_max_body_size 1G;
proxy_set_header X-Forwarded-For $remote_addr;
location /api {
proxy_pass http://127.0.0.1:3333;
}
location /apub {
proxy_pass http://127.0.0.1:3333;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Path $request_uri;
}
location /.well-known {
proxy_pass http://127.0.0.1:3333;
}
location / {
if ($http_accept ~* "application/activity\+json") {
rewrite ^(.*)$ /apub$1;
}
if ($http_content_type = application/activity+json) {
rewrite ^(.*)$ /apub$1;
}
proxy_pass http://127.0.0.1:4333;
}
}
Finally, run the following command:
systemctl restart nginx
So what we've done here is we've taken the two servers on different ports and brought them together on one high capacity webserver to make them available on the common port 80.
Myself, I'm behind a firewall and I'm using a reverse proxy and letsencrypt to expose this website on https to the outside world, but unfortunately I can't say much about how to accomplish this, but this should be plenty to get you started!
sj_zero@lotide.fbxl.net 2 years ago
Of course, immediately after posting I realized something changed.
export FRONTEND_URL="[Your website URL]"
Needs to be in hitide.sh