Fediverse/Installation documentation

From XPUB & Lens-Based wiki

part of the Fediverse explorations and installation of the XPUB Mastodon instance (April-June 2025)

Install Mastodon as a software

Following this Installation guide
This guide assumes a bunch of things are already installed, but if you don't have them on your system you will have to install them. We provide here additional guidance because we don't have anything installed. In order to use the installation commands from the guide, we need to log into the root with su and then run the commands

System packages > Yarn

After enabling corepack, the documentation doesn't say it but you should install yarn by just writing yarn in the terminal

Creating the mastodon user

adduser doesn't work? here's how to resolve it:
Unhide the adduser command using the following command:

sudo update-alternatives --install /bin/adduser adduser /usr/sbin/adduser 20

Then run again

adduser --disabled-password mastodon

Setting up Mastodon

To login into the mastodon account, use:

su mastodon

Installing Ruby

All the commands should be ran one by one!!! - make sure to be in the mastodon user as indicated by the tutorial
To resolve the problem about installing rbenv with jemalloc, we do:

exit # out of the mastodon user to go back to root
apt-get install libjemalloc-dev
su - mastodon
RUBY_CONFIGURE_OPTS='--with jemalloc' rbenv install 3.4.4
rbenv global 3.4.4

Installing the last dependencies

Install bundler by running (in root)

apt install bundler
apt install gem

Then run the installation commands (in mastodon user):

bundle config deployment 'true'
bundle config without 'deployment test'
bundle install -j$(getconf _NPROCESSORS_ONLN)
yarn install

When this returns a "no such file or directory" error:

RAILS_ENV=production rails mastodon:setup

Navigate to the live folder and run:

bundle install
RAILS_ENV=production bin/rails mastodon:setup
Success-fediverse.png




SETTING UP PostGreSQL host: /var/run/postgresql
PostGreSQL port: 5432
Name of PostGreSQL database: mastodon_production
Name of PostGreSQL user: mastodon
Password for PostGreSQL user:
Redis host: localhost
Redis ports: 6379
Redis password: [empty]
Store on the cloud? No
Send e-mails from localhost? No
SMTP server: smtp.mailgun.org (to reconfigure later, leave the following SMTP prompts empty by hitting enter)
Do you want Mastodon to periodically check for updates and notify you? Yes
Save configuration? Yes
Prepare database now? Yes
Compile the assets now? Yes (we will go back to that later cause it logged errors)
Create admin right away? Yes
Username: admin
E-mail: m.berends@hr.nl
Temp password:

Switch back to root!

systemctl restart mastodon*

Acquiring an SSL certificate

Use the example.com commands, they will be editable later, but you should already have a (sub)domain name registered.
If encountering "An unexpected error" when trying to generate certificate, run

apt install python3-certbot-nginx

Setting up nginx

If you get an error while running systemctl restart nginx to apply changes, ask Manetta for help

Setting up systemd services

$EDITOR might not work, if that is the case, just replace it with nano or your preferred text editor

Finally, out of root:

sudo reboot now
Additional info

The git repo of Mastodon is in /home/mastodon/live
To remove the "dubious ownership", we ran git config --global --add safe.directory /home/mastodon/live/.git

We wanted to make sure that Mastodon services are well running:

cd /etc/systemd/system
systemctl status mastodon-web

We saw that Mastodon is not running, so we went into the log file:

journalctl | grep mastodon-web

With that, we discovered that there is a problem around the ruby installation so we went back to the Mastodon installation guide, to the ruby installation part and re-ran the commands one by one. But that didn't solve it... What we did to fix that is actually remove the .rbenv files and start again from the ruby installation.

Configuring environment

The guide

>:((((

The date is 06-06-2025. We are just now learning that LOCAL_DOMAIN and WEB_DOMAIN are supposed to be written very carefully for they cannot be changed safely. The thing is, we did change them (recklessly) and it is probably what is causing the "After logging in to the admin account" errors :)))









Troubleshooting

mastodon-web is still not running: the xvm VPN IP address is blocked so we followed these steps:

cd mastodon/live
nano .env.production

at the end of the file, add the following lines:

RAILS_LOG_LEVEL=debug
LOG_LEVEL=silly

in the beginning:

LOCAL_DOMAIN=404.xpub.nl
WEB_DOMAIN=404.xpub.nl
systemctl restart mastodon*

Error logs from /var/log/nginx/:

2025/06/02 16:40:42 [error] 19943#19943: *1355 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.1, server: 404.xpub.nl, request: "GET /favicon.ico HTTP/1.0", upstream: "http://127.0.0.1:3000/favicon.ico", host: "10.0.0.19", referrer: "https://404.xpub.nl/"
2025/06/02 16:40:42 [error] 19943#19943: *1355 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.1, server: 404.xpub.nl, request: "GET /favicon.ico HTTP/1.0", upstream: "http://127.0.0.1:3000/500.html", host: "10.0.0.19", referrer: "https://404.xpub.nl/"

Error logs from journalctl -u mastodon-web.service -f:

Jun 02 16:46:46 debby bundle[22928]: E, [2025-06-02T16:46:46.036606 #22928] ERROR -- : [ActionDispatch::HostAuthorization::DefaultResponseApp] Blocked hosts: 10.0.0.19
How we fixed the issue

Following this reddit post, we added the ip address 10.0.0.19 to "allow hosts" in the ruby config file, which we found with this command:

find . -iname production.rb

and then opened:

 nano /home/mastodon/live/config/environments/production.rb

This caused another error: it started to redirect http://10.0.0.19 to https://10.0.0.19.

To solve this... we figured out that we need to LIE to mastodon... Michael found this great blog post that explained it: https://blog.vyvojari.dev/mastodon-behind-a-reverse-proxy-without-ssl-https/

We changed the nginx config:

nano /etc/nginx/sites-enabled/mastodon

and changed this line in location @proxy:

#proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto https; # the lie is right here (!!!! we love it, sometimes you need to lie)

This resolved the redirect error!!

Then, we restarted nginx and mastodon... and:

NEXT ERROR

An error popped up in the journalctl:

journalctl -u mastodon-web -f

Which listed the error about the assets package not being able to download.

So we went back to the step that failed in the interactive setup wizard... and ran:

RAILS_ENV=production bin/rails assets:precompile

which gave the same errors again...

Michael suggests to run yarn install again, which was successful.

After that, we ran the command above again (assets:precompile)... (which seems to work now!!)

woohoo, different error!!! an elephant-mashing-the-keyboard-error (500), but this is good news, the server is responding.

a screenshot of an error message during the mastodon instance installation

Since now the errors were pointing at some missing assets, Michael had a hunch about the yarn install part and found this post where someone suggested to remove the yarn.lock file.

Afterwards yarn install threw an error, but we simply re ran RAILS_ENV=production bin/rails assets:precompile and then everything installed correctly.


Afterwards we opened the journal in follow mode to check what happens when someone connects to the landing page, and everything worked fine with no errors.

To avoid having a cluttered output, we commented out the debug lines we added previously at the bottom of the /live/.env.production file

After logging in to the admin account

On June 6th, we logged in to the admin account, but we started encountering various errors:

  • "Connection time out" when trying to access the Settings page, because the url redirects to the IP instead of staying on the domain.

We then looked at the journal of mastodon-streaming

journalctl -u mastodon-streaming@4000 -f

and discovered a big amount of errors regarding the head of the url, which returns two things, 10.0.0.19 and 10.0.0.1, not 404.xpub.nl.

It then tries to get to the api section, failing in loading it because the head is wrong.

Error-node-header-url.png

We continued reading the next section of the installation (Configuring your environment), after the section we just cleared (install from source), and found out a nasty message.

Very-bad-documentation.png

Pretty dark. We did modify both local domain and web domain for sure, because when we had issues with "blocked hosts" we found a reddit post that was talking about these two variables in the live/.env.production file. We tried getting the rails console working to check ENV[WEB_DOMAIN], but we got an error saying that RAILS_ENV is not set so the console does not open.

Notes Manetta

6 June, 15:00

Diving into this error...

journalctl -u mastodon-streaming@4000 -f says:

Jun 06 14:27:46 debby node[52026]: {"level":"error","time":1749212866199,"pid":52026,"hostname":"debby","name":"streaming","req":{"id":"874c2d6d-4e89-41cc-ae80-e239872e1e27","method":"GET","url":"/api/v1/streaming/?","query":{},"params":{},"headers":{"host":"10.0.0.19","x-real-ip":"10.0.0.1","x-forwarded-for":"10.0.0.1","x-forwarded-proto":"http","connection":"close","user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:139.0) Gecko/20100101 Firefox/139.0","accept":"*/*","accept-language":"en-GB,en;q=0.5","accept-encoding":"gzip, deflate, br, zstd","sec-websocket-version":"13","origin":"https://404.xpub.nl","sec-websocket-protocol":"[Redacted]","sec-websocket-extensions":"permessage-deflate","sec-websocket-key":"[Redacted]","sec-gpc":"1","cookie":"[Redacted]","sec-fetch-dest":"empty","sec-fetch-mode":"websocket","sec-fetch-site":"same-origin","pragma":"no-cache","cache-control":"no-cache"}},"err":{"type":"RequestError","message":"Unknown channel requested","stack":"RequestError: Unknown channel requested\n    at authenticationMiddleware (file:///home/mastodon/live/streaming/index.js:540:12)\n    at Layer.handle [as handle_request] (/home/mastodon/live/node_modules/express/lib/router/layer.js:95:5)\n    at trim_prefix (/home/mastodon/live/node_modules/express/lib/router/index.js:328:13)\n    at /home/mastodon/live/node_modules/express/lib/router/index.js:286:9\n    at Function.process_params (/home/mastodon/live/node_modules/express/lib/router/index.js:346:12)\n    at next (/home/mastodon/live/node_modules/express/lib/router/index.js:280:10)\n    at Function.handle (/home/mastodon/live/node_modules/express/lib/router/index.js:175:3)\n    at router (/home/mastodon/live/node_modules/express/lib/router/index.js:47:12)\n    at Layer.handle [as handle_request] (/home/mastodon/live/node_modules/express/lib/router/layer.js:95:5)\n    at trim_prefix (/home/mastodon/live/node_modules/express/lib/router/index.js:328:13)","name":"RequestError","status":400},"msg":"RequestError: Unknown channel requested"}

So... RequestError: Unknown channel requested

Rewinding for a second... where are all the config files again??

  • nano .env.production: rbenv config, log levels can be set here
  • nano /home/mastodon/live/config/environments/production.rb: ruby production config
  • nano /etc/nginx/sites-enabled/mastodon: nginx config

And the logs:

  • journalctl -u mastodon-web -f
  • journalctl -u mastodon-streaming -f
  • journalctl -u mastodon-streaming@4000 -f
  • tail -f /var/log/nginx/access.log
  • tail -f /var/log/nginx/error.log
  • nano /home/mastodon/live/log/ - but this folder stays empty for some reason...

Add Glitch-Soc to the Mastodon installation

From this installation guide