Skip to content

Mastodon

In this article


Information

Mastodon - the decentralized social platform that is free and open source. Unlike commercial platforms that are centralized, Mastodon is not controlled by any single organization.

Mastodon. Key Features

  • Mastodon enables users to subscribe and communicate with other users from any connected server;
  • The platform offers public post feeds to help users discover interesting content. The local feed displays posts from your server, while the federated feed displays all public posts of subscribed users from your server that are known to your server;
  • Users can interact with posts directly in the feed or in the advanced post view by replying, sharing, adding to favorites, bookmarking, or using an additional menu;
  • Mastodon sends notifications for various interaction events related to your profile and posts. These notifications can be filtered by type;
  • To subscribe to a user, simply click the Follow button on their profile. You can also enable notifications for new posts from your subscriptions; The search function in Mastodon allows you to find users, hashtags, and posts via a link. With full-text search installed, you can search your own posts and favorites;
  • Private posts in Mastodon are only visible to subscribers. They are shown in a separate dialog column;
  • The subscription lists can be used to view the post feed exclusively.

Features of the assembly

  • Installed software

    Software Version License
    Mastodon 4.2.1 AGPLv3
    Nginx 1.24.0 Custom
    Postgres 16.1 Postgres SQL
    Certbot 2.1.0 Apache 2
    Redis 7.2.3 BSD-3-Clause
  • Mastodon can be installed on:

    • Ubuntu latest versions.
  • The minimum system requirements for installation:
    • Processor with 2 cores;
    • 2 GB of RAM;
    • Disk space requirement is 30 GB on HDD.
  • Recommended system requirements:
    • 64-bit processor with 4 cores;
    • 8 GB of RAM;
    • 80 GB of SSD storage space.

The link to access the web interface will be: https://mastodon{Server_ID_from_Invapi}.hostkey.in

Getting started after deploying Mastodon

A notification will be sent to the e-mail specified during registration that the server is ready for work after paying for the order. It will contain the IP address of the VPS, as well as the login and password for the connection. Clients of our company manage the hardware in the server and API control panel — Invapi.

You can find the authorization data either in the Info >> Tags tab of the server control panel or in the email that was sent.

  • Link to access the Mastodon dashboard with a web interface: in the webpanel tag;
  • Login and Password can be found in the credentials tag

Configure change

To change the Mastodon configuration from the command line, use the tootctl and rails utility:

  • Account settings, create, modify, assign permissions, etc;
  • SMTP server settings;
  • User registration settings.

Information

Refer to the developer documentation for more information on how to use the utilities.

Example Usage

Use the command line to change the user:

su - mastodon

Next, navigate to the directory:

cd /home/mastodon/live

Create a moderator account:

RAILS_ENV=production bin/tootctl accounts create name_moderator --email [email protected] --role Moderator --confirmed

After executing these commands, a new user named 'name_moderator' will be created with moderator rights and a validated account. The password will be specified in the output of the last command.

To modify Mastodon's configuration, such as the mail server, you must edit the configuration file /home/mastodon/live/.env.production.

After making the changes, execute:

su - mastodon
cd /home/mastodon/live/
RAILS_ENV=production bundle exec rails assets:clean
RAILS_ENV=production bundle exec rails assets:clobber
RAILS_ENV=production bundle exec rails assets:precompile

After executing these commands, Mastodon will accept the updated settings.

Information

Refer to the developer documentation for more information on configuration settings.

Working with the mail server

In this build, Mailserver is installed in a Docker container. To use Mastodon, you need to have an SMTP server. To modify Mailserver settings, access the container environment using the following command:

docker exec -it mailserver bash

To exit the environment, press Ctrl+D or type exit.

Information

Refer to the developer documentation to learn more about working with the mail server.

The setup script inside the container can be used to configure mail addresses and forwarding:

docker exec -it $mailserver bash
setup alias add [email protected] [email protected]
exit

The following commands were used to migrate to the mailserver container and set up mail forwarding: incoming mail addressed to [email protected] will be redirected to the [email protected] email address.

Information

Refer to the developer documentation for more information on how to work with setup.sh.

Changing the domain name of the Mastodon server

To change the domain name, follow these steps:

  1. Register your own domain, for example, mastodon.mydomain.com.

  2. Configure DNS records for this domain:

    • Specify an A-record that points to the IP address of the Mastodon server;
    • Configure an MX record pointing to the mail server.

    Information

    DNS management

  3. SSH into the Mastodon server and edit the Nginx configuration file:

    /etc/nginx/sites-available/mastodon
    
  4. Update the server_name parameter to reflect the new domain;

  5. Restart Nginx:

    sudo systemctl restart nginx
    
  6. In the Mastodon administration settings, update the domain to the new one and save the changes;

  7. Configure email notifications;

  8. Create a new email account with the address notifications@new_domain_name. The new_domain_name should match the mail server's domain.

  9. Access the Docker container for the mail server by logging in:

    docker exec -it $mailserver bash
    
  10. Add a new account:

    setup email add notifications@(new_domain_name) '(password)'
    
    • Please set a password for this account.
    setup config dkim keysize 2048 domain (new_domain_name)
    
  11. Exit the container:

    exit
    

    After executing the commands above, the /root/mailserver/docker-data/dms/config/opendkim/keys/(new domain name)/mail.txt file will contain the information necessary to configure a DNS record of _domainkey type with the domain registrar. This record is essential for the proper operation of the mail server using DKIM technology. Without it, messages sent from this domain may be blocked by recipients as invalid, for example, by services like Gmail.

  12. Add a PTR record to the IP address settings in Invapi;

    Information

    Learn how to set up a PTR record in Invapi by following these.

  13. Edit the .env.production file located in the home directory of the mastodon user:

    • Update the LOCAL_DOMAIN parameter with the new domain;
    • Update SMTP settings to match the current mail server. Specify the login and password from dovecot-master, root, and the original password received during server handover.
  14. Recompile the assets:

    su - mastodon
    cd /home/mastodon/live/
    RAILS_ENV=production bundle exec rails assets:clean
    RAILS_ENV=production bundle exec rails assets:precompile
    
  15. Restart Mastodon:

    sudo systemctl restart mastodon-*.service   
    

Changing the domain name of a mail server

To change the domain name of a mail server, follow these steps:

  1. Stop all Docker containers currently running:

    docker stop $(docker ps -q) 
    
  2. Delete all Docker containers that have stopped:

    docker rm $(docker ps -q)
    
  3. Locate the hostname parameter in the docker-compose.yml file, search for a line that matches the following format:

    hostname: mastodon*.hostkey.in
    
  4. Replace the hostname parameter value with the desired domain:

    hostname: mydomain.com
    
  5. Save the changes in the docker-compose.yml file.

  6. Start Docker containers:

    docker-compose up -d
    

After completing these actions, the mail server's domain name will be changed to the specified domain.

Then, verify access to the new domain and ensure all functions are operational.

Administrator panel initial settings

To access the admin panel, follow the link from the webpanel tag, click on Sign In, and enter the credentials from the credentials tag.

To modify a user's information, click the Edit Profile button located below the user's name.

.

Managing server rules

Administrators and moderators of each individual server in this decentralized social network set the rules for Mastodon. To manage rules, go to Administration >> Server Rules.

Basic principles for setting rules:

  • Ensure that rules are reasonable and follow generally accepted standards of decency to avoid discouraging users;
  • Clearly state prohibited content types, such as cruelty, violence, and illegal activities, and clarify acceptable levels of NSFW content;
  • Specify procedures for warning, blocking, or restricting rule violators, as well as disciplinary actions and time limits;
  • The server rules must be easily accessible to all users and publicly displayed during registration;
  • It is important to periodically review and update the rules as the server grows, and involve the community in the process of modding and improving them.

Inviting users

Mastodon has multiple tabs in the feed for managing subscriptions and inviting new users:

  • Follows and Followers - this tab displays the accounts to which the current user is subscribed, and the feed will show entries from these users. Additionally, this tab lists those who are subscribed to this account, which is the audience in Mastodon.
  • Invite people - function allows users to invite friends and acquaintances to their social network. This text describes the creation of a unique link that can be shared to allow other users to join the Mastodon server.

.

Note

For detailed information on basic Mastodon settings, refer to the developers' documentation.

Ordering a server with Mastodon using the API

curl -s "https://invapi.hostkey.com/eq.php" -X POST \
--data "action=order_instance" \
--data "token=" \
--data "deploy_period=" \
--data "deploy_notify=" \
--data "email=" \
--data "pin=" \
--data "id=" \
--data "os_id=" \
--data "root_pass=" \
--data "hostname=" \
--data "ssh_key=" \
--data "post_install_callback=" \
--data "post_install_script=" \
--data "reinstall_key=" \
--data "os_name=" \
--data "imitate_deploy=" \
--data "imitate_error=0" \
--data "own_os=" \
--data "jenkins_task=" \
--data "traffic_plan=" \
--data "invoice_relid=" \
--data "preset=" \
--data "location_name=" \