Installing Mastodon on Unraid
I recently discovered Mastodon and wanted to give it a try but couldn’t find any guides on the internet that went over how to install it on Unraid. After a bit of hair pulling I managed to figure it out. So without further ado, here is how I did it.
Get the necessary containers
Go to docker settings in Unraid and click “Add Container” we’re going to need three. I’ve linked the three I used from dockerhub below. It’s important that you setup PostgreSQL and Redis before the Mastodon container.
- PostgreSQL PostgreSQL is a powerful, open source object-relational database system.
- Redis An open source, in-memory data structure store, used as a database, cache and message broker.
- Mastodon Mastodon is a free, open-source social network server based on ActivityPub where users can follow friends and discover new ones.
Redis
This one is pretty simple as the only setting to enter here is the Redis Port. I’d recommend using the default of 6379.
- Port: 6379
PostgreSQL
Here we need to setup a few more settings, including a host path for the postgres data, the name of our database, a postgres user and password, and finally the port.
- Host Path: /mnt/user/appdata/postgresql
- DB_NAME: mastodon
- DB_USER: mastodon
- DB_PASS: MySuperSecretPassword
- PORT: 5432
Mastodon
Oh boy, there are a lot of settings for Mastodon. You’ll start out by leaving OTP_SECRET, SECRET_KEY_BASE, VAPID_PRIVATE_KEY, and VAPI_PUBLIC_KEY blank. We’ll fill them in later. For now, just fill in the following settings:
- Web Port: 3000
- Streaming Port: 4000
- Mastodon Files: /mnt/user/appdata/mastodon
- DB_HOST: The IP address or hostname of the docker container running PostgreSQL
- DB_USER: The user you set in your docker container for PostgreSQL above.
- DB_NAME: The database name you created for use with Mastodon in PostgreSQL.
- DB_PASS: The password you set for the user in PostgreSQL above.
- REDIS_HOST: The IP address or hostname of the docker container running Redis.
- LOCAL_DOMAIN: The domain or subdomain you’ll be hosting Mastodon on. E.g. social.mydomain.com
- SMTP_SERVER: Your smtp address. E.g. for gmail smtp.gmail.com
- SMTP_PORT: SMTP Port E.g. 25
- SMTP_LOGIN: The username to login to your mail server.
- SMTP_PASSWORD: The password for the e-mail account
- SMTP_FROM_ADDRESS: The e-mail address you’d like Mastodon to appear to send from.
Configuring and Starting Mastodon
- Start your Redis and PostgreSQL containers if you haven’t already.
- Next, start Mastodon. At this point we don’t expect it to be accessible or working but we need to use the container to generate some secrets for the blank variables we created earlier.
If the Mastodon container won’t start make sure that the Redis and PostgreSQL containers are already started and configured properly.
{.is-info}
- Access the Mastodon console from Unraid by going to Docker > Left Clicking on the ‘Mastodon’ container and selecting ‘Console’
- Run these commands to generate your secrets:
|
|
The rake secret command was ran twice on purpose above. The result should look something like this:
|
|
- Copy the first rake secret, edit your Mastodon container, and enter that value for OTP_SECRET, use the second secret value for SECRET_KEY_BASE.
- Now, do the same for your VAPID_PRIVATE_KEY and VAPID_PUBLIC_KEY with the values produced from the generate_vapid_key command.
- At this point you should be able to restart the Mastodon container and access it at http://YOURIP:3000 (if you used the default port)
Stopping Redirection
If you use CloudFlare be warned that you may have to turn off the proxy setting for your instance to properly federate or to follow remote users.
{.is-warning}
At this point Mastodon should start and produce no errors in the docker console.
However, on my setup I found out it was redirecting me from http://xxx.xxx.xxx.xxx:3000/ to https://xxx.xxx.xxx.xxx without the port.
This is because Mastadon runs its own copy of Nginx that redirects non-SSL traffic to SSL without keeping the port. To fix this, I needed to put Mastadon behind my reverse proxy that had SSL enabled already so it wouldn’t try to redirect.
This is making my site available at https://social.fixflare.com
|
|
Making yourself Admin
- Go ahead and access the Mastodon page (https://social.yourdomain.com) and sign up for a new account:
- If you setup your e-mail settings properly this should send you a confirmation link to your e-mail address. Login to your e-mail and confirm the registration.
- Access the Mastodon console again by going to Unraid > Docker > Left Clicking on the ‘Mastodon’ container and selecting ‘Console’
- Grant yourself administrative access by running this command, replace ‘YourUser’ with the username you signed up with excluding the ‘@’
|
|
Finishing Up
After logging in, navigate to preferences, administration, Site settings page. While there are no technical requirements for filling in this information, it is considered crucial for operating a server for humans.
Contact username: Your username so people know who owns the server
Business e-mail: An e-mail address so people locked out of their accounts, or people without accounts, can contact you
Instance description: Why did you start this server? Who is it for? What makes it different?
Custom extended information: You can put all sorts of information in here but a code of conduct is recommended
After you fill these in, simply hit “Save changes”.
You should now have a functional, working, Mastodon server running from Unraid. Now get Tooting!
If you’re looking to federate with some other servers at the start. Try adding a relay to https://relay.mastodon.host/