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 for connecting to the server: sent via email to your address once the server is ready after software deployment;
  • Login and Password for authenticating in the Mastodon web interface are set manually during account creation through the administrator's console.

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. Log into the Mastodon web application container. Find and connect to the mastodon_web_1 container:

    docker exec -it mastodon_web_1 bash
    

  3. To create a new user, use the command tootctl accounts create. Specify the username, email, and the --confirmed flag for account confirmation.

    RAILS_ENV=production bin/tootctl accounts create new_username --email [email protected] --confirmed
    
    Replace new_username with your desired username and [email protected] with the actual email of the user. After executing this command, the user will be created. Be sure to save the password displayed on screen:

Granting Administrator Privileges and Approving User

After creating a user, you need to find them in the database to change their permissions and status.

  1. Start the Rails console:
    RAILS_ENV=production bin/rails console
    
  2. Find the user by email or username:
    user = User.find_by(email: '[email protected]')  # or: User.find_by(username: 'new_username')
    
  3. Update their status:

    user.update(approved: true)
    
    This action will remove the notification Your application is pending review by our staff... from the admin panel.

  4. Assign them an administrative role:

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

  5. Verify:
    user.reload
    
    user.role           # => "Admin"
    
    user.approved       # => true
    
  6. Exit the console:
    exit
    

Configuring Mail Server

If you need to configure or change the mail server, execute:

  1. Open the configuration file:

    nano /opt/mastodon/.env.production
    
    2. Configure SMTP parameters (e.g., for MailHog):

    # Sending mail
    # ------------
    SMTP_SERVER=mailhog
    SMTP_PORT=1025
    SMTP_LOGIN=
    SMTP_PASSWORD=
    SMTP_FROM_ADDRESS=notifications@your_domain
    SMTP_AUTH_METHOD=none
    SMTP_OPENSSL_VERIFY_MODE=none
    SMTP_ENABLE_STARTTLS=false
    
    3. Restart Mastodon containers To apply new settings, restart the Mastodon containers:

    cd /opt/mastodon
    
    docker-compose restart
    
    4. Check email functionality - For MailHog: open the web interface http://your_server:8025 - Check logs:
    docker-compose -f /opt/mastodon/docker-compose.yml logs sidekiq | grep -i mail
    
    - Test it out: register a new user and check for email receipt

Notes

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

 docker ps
Make sure Mastodon containers (mastodon_web_1, mastodon_db_1, etc.) are running.

Information

Learn more about configuration settings in the Developer Documentation.

Information

Find out more about working with setup.sh in the Developer Documentation.

Changing Mastodon Server Domain Name

Information

This guide uses skaz.online as an example domain. Initially, Mastodon is configured with a domain like mastodon<server_ID>.hostkey.in. Replace skaz.online with your actual domain in all configuration examples.

Key Files and Directories

File/Directory What Changes
/opt/mastodon/.env.production Environment variables, domains
/data/nginx/user_conf.d/*.conf Nginx configuration for the new domain
/etc/letsencrypt/live/ SSL certificates (if using certbot)
Docker Compose files Domain in docker-compose.yml or variables
SMTP Configuration Update addresses related to the domain

To change the domain name, follow these steps:

  1. Register your own domain, e.g., mastodon.mydomain.com.

  2. Configure DNS records for this domain:

    • Set an A-record pointing to the Mastodon server's IP address;
    • Configure MX record pointing to the mail server.

    Information

    DNS Management

  3. Add a PTR record in IP address settings on Invapi; !!! info "Information" Learn more about setting up PTR records in Invapi here.

  4. Update Mastodon Environment Variables Edit the file /opt/mastodon/.env.production, replacing the current value (e.g., mastodon<server_ID>.hostkey.in) with your new domain:

    # Previous:
    # LOCAL_DOMAIN=mastodon<server_ID>.hostkey.in
    
    # Updated:
    LOCAL_DOMAIN=skaz.online
    WEB_DOMAIN=skaz.online
    
    5. Set up Nginx with HTTPS Support

    5.1 Create Nginx Configuration Important: Create a new configuration file, replacing the old one. Old configurations may contain different proxy_pass directives, leading to malfunction. Create an Nginx configuration file /data/nginx/user_conf.d/skaz.online.conf with the following content:

    server {
        listen 80;
        server_name skaz.online;
        return 301 https://$host$request_uri;
    }
    server {
        listen 443 ssl;
        listen [::]:443 ssl;
        server_name skaz.online;
    
        # SSL certificates
        ssl_certificate         /etc/letsencrypt/live/skaz.online/fullchain.pem;
        ssl_certificate_key     /etc/letsencrypt/live/skaz.online/privkey.pem;
        ssl_trusted_certificate /etc/letsencrypt/live/skaz.online/chain.pem;
        ssl_dhparam /etc/letsencrypt/dhparams/dhparam.pem;
    
        # Main Mastodon application (port 3000)
        location / {
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Forwarded-Ssl on;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:3000;
            real_ip_header X-Forwarded-For;
            # WebSocket support
            proxy_http_version 1.1;
            proxy_set_header X-Scheme $scheme;
            proxy_buffering off;
        }
    
        # Mastodon Streaming API (port 4000)
        location ^~ /api/v1/streaming {
            proxy_set_header X-Forwarded-Proto https;
            proxy_set_header X-Forwarded-Ssl on;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Host $host;
            proxy_set_header X-Forwarded-Server $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_pass http://127.0.0.1:4000;
            real_ip_header X-Forwarded-For;
            # WebSocket support
            proxy_http_version 1.1;
            proxy_set_header X-Scheme $scheme;
            proxy_buffering off;
        }
    }
    
    5.2 Obtain SSL Certificate Check for the certificate:
    docker exec -it mastodon-nginx-1 ls /etc/letsencrypt/live/
    
    If the certificate is missing, obtain it:
    docker compose stop nginx
    
    docker compose run --rm nginx certbot certonly --standalone -d skaz.online
    
    docker compose start nginx
    

  5. Clean Up Conflicting Configurations

Important! Remove old Nginx configurations as multiple .conf files can cause conflicts: Delete the old configuration (e.g., for mastodon<server_ID>.hostkey.in)

rm /data/nginx/user_conf.d/mastodon<server_ID>*.conf
Or rename to keep a backup

mv /data/nginx/user_conf.d/mastodon<server_ID>.hostkey.in.conf /data/nginx/user_conf.d/mastodon<server_ID>.hostkey.in.conf.backup

Reasons for conflicts:

  • Duplicate listen 443 ssl directives cause an error duplicate listen options
  • Old configurations might have different proxy_pass addresses or ports
  • Nginx may misinterpret requests with multiple server blocks

  • Restart Services In the directory containing docker-compose.yml, execute:

    docker compose down
    
    docker compose up -d
    

  • Verify Functionality Testing from the command line

    curl -Ik https://skaz.online
    
    Expected response: HTTP/1.1 200 OK Check in a browser Open the domain in a browser — the Mastodon homepage should load.

Administrator panel initial settings

To access the administrator panel, follow the link from the webpanel tag, click on the Log In button, and enter the credentials set earlier.

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.


Some of the content on this page was created or translated using AI.

question_mark
Is there anything I can help you with?
question_mark
AI Assistant ×