There’s a ds106 Social Going On in Mastodon!

Rhyming post titles will cost you extra! 🙂

I got sucked down an elephant-sized rabbit hole the last couple of days taking the bait to see if I could get a Mastodon server up and running for ds106. Guess what….NOBODY!

As usual, it’s never a solo effort. My first go-around Tuesday morning was plagued with errors and issues when trying to install from Docker, so I switched quickly to using an Ubuntu 20.x VPS in Reclaim Cloud, and while I got further than with the docker image following this guide for installing Mastodon on a VPS, I still got jettisoned on the nginx setup (although there could have been much more wrong for sure).

Two-hour stream of Taylor and I figuring out how to install mastodon on Reclaim Cloud

But hope springs eternal, so later on Tuesday Taylor Jadin and I jumped on a stream in Reclaim Edtech’s Discord and walked through setting up Mastodon in a Debian 11.5 VPS, and this time it worked thanks to Taylor’s sysadmin kung-fu. Taylor’s mastodon notes can work in tandem with this official installation guide from Mastodon, and it just might get you where you want to go. Taylor’s notes outline the following:

If you get an error while running this command, you can ignore it:

cd ~/.rbenv && src/configure && make -C src

And when you exit back to root user in the guide be sure to start both postgresql and redis using the following two commands:

systemctl start postgresql
systemctl start redis

Also, when you get to the Mastodon setup command that prompts you for the domain, postgresql settings, redis settings, etc., you’re going to want to have a domain where your Mastodon lives (changing that post facto might be hairy), SMTP credentials for an email through something like Mailgun, and finally a S3 bucket setup on a service like AWS’s S3, Minio, or some other S3 compatible tool.* You can just use default values and ignore passwords for the postgre and redis prompts of the setup, but you will need values for the domain, e-mail, and S3 media offload values.

Here are the details you will need for email, using Mailgun in this example:

SMTP_SERVER=smtp.mailgun.org
SMTP_PORT=587
SMTP_LOGIN=postmaster@social.ds106.us
SMTP_PASSWORD=yourSMTPpasswordhere
SMTP_AUTH_METHOD=plain
SMTP_OPENSSL_VERIFY_MODE=none
SMTP_FROM_ADDRESS=’Mastodon <notifications@social.ds106.us>’

Keep in mind the login and password settings will be unique to your setup, but the rest should work unless you are using an EU server for Mailgun, if so the SMTP_SERVER may be different.

Where I ran into the most difficulty is piecing together offloading media to the cloud, and I would recommend doing that beforehand. If you want your server to scale, off-loading media will be important. This excellent guide on setting up AWS for Mastodon got me most of the way there, but my media was ultimately resolving to wonky URLs, and the following setup is what worked for me, again you will need your own bucket name, your specific S3 region, your own AWS key, and AWS secret.

S3_ENABLED=true
S3_BUCKET=reclaimsocialdev
AWS_ACCESS_KEY_ID=yourAWSkeyhere
AWS_SECRET_ACCESS_KEY=yourAWSsecretaccesskeyhere
S3_REGION=us-east-1
S3_PROTOCOL=https
S3_HOSTNAME=s3.amazonaws.com

The issue I ran into was the the different methods (and URL structures) for accessing media through AWS’s S3. This is a bit of a breakdown from their documentation, but long story short I wanted virtual-hosted style buckets rather than  paths-style buckets. Seems the latter are being deprecated by AWS, and for some reason beyond my understanding the URLs in Mastodon were using the path-style structure. I may have messed this up in the setup given I off-loaded media to the cloud after the instance was successfully setup—be better than me. When you are prompted to choose S3 bucket style, chose virtual buckets, or something equivalent. Even better, setup a CNAME alias that re-writes reclaimsocialdev.s3.amazonaws.com to something like files.ds106.us. I might still do this, but for now it’s working, and that’s not nothing given the hours sunk into this issue.

Once you get through the setup, there is going to be one last trick when you get the nginx part of the install guide from Mastodon. This was a bear for me given my limited understanding of nginx, but when working through it with Taylor we figured something out. Namely that when starting nginx (systemctl start nginx) you need to uncomment these two lines in the /etc/nginx/sites-available/mastodon file.

#listen 443 ssl http2;
# listen [::]:443 ssl http2;

And below them add these two lines:

listen 443;
listen [::]:443;

I can’t tell you why nginx starts cleanly after that, but it does. Once it is started and you setup your Let’s Encrypt certificate you can remove the two listen lines I told you to add, and uncomment the two above those. Also, certfbot will add lines to the server block that are duplicates, you will need to comment some of these out. I’m including my nginx config below for the server block in question found at /etc/nginx/sites-available/mastodon. It looks like this:

server {
server_name social.ds106.us;
root /home/mastodon/live/public;
location /.well-known/acme-challenge/ { allow all; }
location / { return 301 https://$host$request_uri; }

# listen [::]:443 ssl ipv6only=on; # managed by Certbot
# listen 443 ssl; # managed by Certbot
# ssl_certificate /etc/letsencrypt/live/social.ds106.us/fullchain.pem; # managed by Certbot
# ssl_certificate_key /etc/letsencrypt/live/social.ds106.us/privkey.pem; # managed by Certbot
# include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
# ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

Be careful given this may not copy lines in cleanly, but shout out to Tim Owens for noting you just need to comment out the lines where there is a “managed by certbot” line in the first server block, which made it easier to delineate. The last bit I struggled with is that if you have both a default and mastodon file in /etc/nginx/sites-available/ you may have to remove the default and rename the mastodon file default, at least that’s what I did. I also then went back in /etc/nginx/nginx.conf and specified the server to look for only the default file in /etc/nginx/sites-available/ rather than /etc/nginx/sites-available/* (which means it will find all files in that folder, I believe). I do realize I am jotting down some half-baked notes, so feel free to reach out with questions given I do know it will not be a straightforward install, no how much advice I provide here. It’s a very complicated install, Maude. You know, a lotta ins, lotta outs, lotta what-have-you’s.

jimgroom account on social.ds106.us mastodon server

Anyway, I think that is a decent breakdown of how I got to the point from which I write this, dear reader, and I also have a ds106 Mastodon server up and running on Reclaim Cloud for my labors. It can scale up to 8 GB right now, but it’s only using between 1-2 GB so far. I estimate it will cost about $24 a month. Add to that another $3 for the IP, and you are up to about $27 a month with no real activity to speak of. I will also be tracking the AWS costs for this media bucket to see what that runs, but I’m guessing maybe $5-$7 a month? So, if you can set one up and are comfortable with a bit of uncertainty around maintaining it, a solid server with offloaded media to S3 will run about $35 a month to start. We’ll see if that proves a solid figure over time, but luckily we control the vertical and the horizontal, so we can scale it baby! This is ds106 after all.

Screenshot of ds106 user on mastodon

ds106 is #4life

___________________________________________

*I had no luck with Digital Ocean’s Spaces or Cloudflare’s R2, so I had to revert to AWS’s S3.

This entry was posted in reclaim, Reclaim Cloud and tagged , , . Bookmark the permalink.

4 Responses to There’s a ds106 Social Going On in Mastodon!

  1. GNA Garcia says:

    We gotta sign up for that or what?

  2. Alan Levine says:

    Thanks for doing this, Jefe. All the server stuff command line judo is impressive but I will be happy to move my home to the one domain that always matters

    • Reverend says:

      Figuring how to stand something like this up is definitely one of my favorite elements of edtech, hence all my WPMU blah blah blah, so getting this up was definitely fun. Plus, I came in a bit like “I don’t care about Mastodon…I don’t want to do that any more” and within hours was like, “Wow, this interface is nice and I actually like having a small, focused, and mellow community to share with again, who knew?” A very early, relaxed Twitter vibe before it was toxic, I can dig that…and then there’s D’Arcy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.