Oct 25, 2024 3 min read

Misskey: Your Self-Hosting Setup and Management Guide

Misskey: Your Self-Hosting Setup and Management Guide
Table of Contents

Misskey is a decentralized, open-source microblogging platform designed for customization and seamless integration with the fediverse. It’s an excellent choice for self-hosting because it grants full control over data, extensive configuration options, and the ability to scale as needed. In this guide, we’ll walk you through deploying Misskey, setting up a robust environment with Docker or manual installation, configuring Nginx as a reverse proxy, managing logs, automating backups, updating the app, and leveraging its unique features.

Installing Misskey

πŸ“¦ Docker/Docker Compose Setup

Docker is the most convenient way to deploy Misskey. Below is a tailored docker-compose.yml file for deploying Misskey.


version: '3.7'

services:

misskey:

image: misskey/misskey:latest

container_name: misskey

restart: always

ports:

- "3000:3000"

environment:

POSTGRES_HOST: db

POSTGRES_USER: misskey

POSTGRES_PASSWORD: your-password

POSTGRES_DB: misskey

REDIS_HOST: redis

volumes:

- ./misskey_data:/misskey

depends_on:

- db

- redis

db:

image: postgres:15

container_name: misskey_db

restart: always

environment:

POSTGRES_USER: misskey

POSTGRES_PASSWORD: your-password

POSTGRES_DB: misskey

volumes:

- ./postgres_data:/var/lib/postgresql/data

redis:

image: redis:7

container_name: misskey_redis

restart: always

Save this file as docker-compose.yml, then deploy Misskey using the following commands:


mkdir -p ~/misskey/{misskey_data,postgres_data}

## Deploy Misskey

cd ~/misskey

docker-compose up -d

πŸš€ Manual Installation

To install Misskey manually on a Linux server, follow these steps:


## Update the system and install dependencies

sudo apt update && sudo apt upgrade -y

sudo apt install -y git curl build-essential libpng-dev

## Install Node.js and Yarn

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -

sudo apt install -y nodejs

npm install --global yarn

## Clone the Misskey repository

git clone --depth=1 https://github.com/misskey-dev/misskey.git

cd misskey

## Install dependencies and build

yarn install

yarn build

## Create a configuration file

cp .config/example.yml .config/default.yml

nano .config/default.yml  # Modify this file with your settings

## Run the database migrations

yarn run migrate

## Start Misskey

NODE_ENV=production yarn start

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

Below is a sample Nginx server block to route traffic to Misskey running on port 3000.


server {

listen 80;

server_name yourdomain.com;

location / {

proxy_pass http://127.0.0.1:3000;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

Save this configuration to /etc/nginx/sites-available/misskey and enable it:


sudo ln -s /etc/nginx/sites-available/misskey /etc/nginx/sites-enabled/misskey

sudo nginx -t  # Test the configuration

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

Secure your installation with Let's Encrypt:


sudo apt install -y certbot python3-certbot-nginx

sudo certbot --nginx -d yourdomain.com

sudo systemctl reload nginx

πŸ› οΈ Testing and Reloading Nginx

Test your Nginx configuration to ensure no issues exist:


sudo nginx -t

sudo systemctl reload nginx

Logging and Debugging Misskey

πŸ—ƒοΈ Enabling Debug Logs

To enable debug logs, update your Misskey configuration file (.config/default.yml) with:


logLevel: debug

Restart Misskey to apply the changes:


docker-compose restart misskey

## For manual installs:

## NODE_ENV=production yarn start

πŸ“„ Viewing Logs

View logs using the following commands:

  • Docker: docker logs -f misskey

  • Manual Install: tail -f logs/*.log

πŸ› οΈ Troubleshooting Common Issues

  • Port conflicts: Ensure no other services are using port 3000.

  • Database connection errors: Verify your POSTGRES_HOST, POSTGRES_USER, and POSTGRES_PASSWORD in the config file.

πŸ“€ Exporting Logs

To forward logs to an ELK stack, use the Docker --log-driver option or configure a syslog service for manual installs.

Backup and Restore

πŸ—‚οΈ File-Based Backups

Archive the misskey_data directory for a full file-based backup:


tar -czvf misskey_backup.tar.gz ~/misskey/misskey_data

πŸ”„ Database Backups

Export your PostgreSQL database with:


docker exec -t misskey_db pg_dump -U misskey -d misskey > db_backup.sql

Restore the database with:


docker exec -i misskey_db psql -U misskey -d misskey < db_backup.sql

πŸ“… Automated Backup Scripts

Automate backups using cron. Example script:


#!/bin/bash

DATE=$(date +%F)

tar -czvf /backups/misskey_$DATE.tar.gz ~/misskey/misskey_data

docker exec -t misskey_db pg_dump -U misskey -d misskey > /backups/db_$DATE.sql

Schedule with crontab -e:


0 2 * * * /path/to/backup_script.sh

Updating and Upgrading Misskey

⬆️ Updating Docker Images

To update Misskey in Docker, run:


docker-compose pull misskey

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installs, pull the latest code and rebuild:


git pull origin master

yarn install

yarn build

yarn run migrate

NODE_ENV=production yarn start

πŸ” Checking for Updates

Check Misskey’s GitHub repository for the latest releases: https://github.com/misskey-dev/misskey

Leveraging Misskey’s Unique Features

πŸ”§ Enabling APIs

To enable the Misskey API, ensure it’s active in your configuration file (.config/default.yml):


api:

enabled: true

Test the API with a simple curl request:


curl -X GET http://yourdomain.com/api/meta

🌟 Advanced Configurations

  • Custom Emojis: Upload emoji packs to the misskey_data/emojis directory.

  • Federation Settings: Adjust federation rules in the configuration file to connect with specific fediverse instances.

Wrapping Up

By following this guide, you’ve successfully deployed, configured, and customized Misskey for your self-hosted needs. Its flexibility and extensive feature set empower you to control your data and tailor the platform to your community’s requirements. Start exploring Misskey’s unique capabilities today!

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Selfhosted Ninja.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.