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.

Deployment Features

ID Compatible OS VM BM VGPU GPU Min CPU (Cores) Min RAM (Gb) Min HDD/SDD (Gb) Active
59 Ubuntu 22.04 + + + + 2 2 - Yes
  • Installed software

    Software License
    Mastodon AGPLv3
    Nginx Custom
    Postgres Postgres SQL
    Certbot Apache 2
    Redis BSD-3-Clause
  • 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

Note

Unless otherwise specified, by default we install the latest release version of software from the developer's website or operating system repositories.

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:Sent to your email address after the server is ready for use following software deployment.

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

  1. Connect to the server via SSH:

    ssh root@<server_ip>
    
  2. Enter the container with the Mastodon web application. Find and connect to the mastodon_web_1 container:

    docker exec -it mastodon_web_1 bash
    
  3. To create a new user, use the tootctl accounts create command. As parameters, specify the username, email, and the --confirmed flag to confirm the account.

    RAILS_ENV=production bin/tootctl accounts create new_username --email [email protected] --confirmed
    

    Replace new_username with the desired username and [email protected] with the user's real email address.

    After executing this command, the user will be created. Be sure to save the password that is displayed on the screen:

  4. Granting Administrator Privileges

    After creating the user, you need to find them in the database for further permission changes. Use the rails console command.

    RAILS_ENV=production bin/rails console
    

    Inside the console, execute the command to search for the user by email or username:

    user = User.find_by(email: '[email protected]')  # or you can use find_by(username: 'new_username')
    

    Once the user is found, you need to update their role by assigning them the administrator role. Use the following command:

    user.update(role: UserRole.find_by(name: 'Admin'))
    

    This command sets the "Admin" role for the selected user.

    To verify that the role has been successfully changed, execute the command:

    user.reload
    user.role
    

    The user's current role ("Admin") will be displayed on the screen.

  5. Exit the Rails Console:

    exit
    
  6. Modifying Mastodon Configuration

    If you need to make changes to the configuration, such as changing the mail server, do the following:

    • Open the configuration file:

      nano /opt/mastodon/.env.production
      
    • After making changes, execute commands to update static files:

      RAILS_ENV=production bundle exec rails assets:clean
      RAILS_ENV=production bundle exec rails assets:clobber
      RAILS_ENV=production bundle exec rails assets:precompile
      
    • Exit the container:

      exit
      
  7. Restarting Mastodon Containers

    To apply the new settings, restart the Mastodon containers as an administrator:

    ```bash
    docker-compose -f /opt/mastodon/docker-compose.yml restart
    ```
    

Note

  1. Checking Docker Containers: If you're unsure which containers are running, execute:

    docker ps
    

    Ensure that the Mastodon containers (mastodon_web_1, mastodon_db_1, etc.) are running.

  2. Error Tracking: If commands in the container produce errors, use the --trace parameter for debugging:

    RAILS_ENV=production bundle exec rails assets:precompile --trace
    
  3. Access Rights: If you encounter access errors to files (e.g., Errno::EACCES), ensure that the files in the /opt/mastodon directory have the correct owner and permissions:

    chown -R mastodon:mastodon /opt/mastodon
    chmod -R 755 /opt/mastodon
    
    • After executing these commands, Mastodon will adopt the new settings.

Information

For more detailed information on configuration settings, refer to the developer documentation.

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.

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

To install this software using the API, follow these instructions.