Fediverse/Installation documentation: Difference between revisions
| Line 139: | Line 139: | ||
====== How we fixed the issue ====== | ====== How we fixed the issue ====== | ||
Following [https://www.reddit.com/r/selfhosted/comments/11esmtt/selfhosted_mastodon_on_docker_getting_blocked/ 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 | find . -iname production.rb | ||
Revision as of 13:04, 3 June 2025
Mastodon glitch-soc installation
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
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.
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.
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
Add Glitch-Soc to the Mastodon installation
From this installation guide
If you encounter the HEAD detached error, you can fix it with:
git branch #to check where you are