Sep 19, 2024 3 min read

Selfoss: A Beginner-Friendly Guide to Self-Hosting

Selfoss: A Beginner-Friendly Guide to Self-Hosting
Table of Contents

Selfoss is a lightweight, open-source web application designed for self-hosting RSS feeds and personal content aggregation. It offers users control over their data, extensive customization options, and a clean, responsive interface. Whether you're a developer seeking a self-hosted solution or a tech-savvy user looking for a powerful RSS reader, this guide will walk you through deploying, configuring, and managing Selfoss step-by-step.

Installing Selfoss

πŸ“¦ Docker/Docker Compose Setup

Using Docker is one of the easiest ways to deploy Selfoss. Here’s how you can set it up with Docker Compose:

  1. Create a docker-compose.yml file:

version: '3.9'

services:

selfoss:

image: selfoss/selfoss:latest

container_name: selfoss

ports:

- "8080:80"

volumes:

- ./data:/var/www/html/data

- ./config.ini:/var/www/html/config.ini

restart: unless-stopped

This configuration maps the application to port 8080, stores data persistently in a ./data directory, and allows configuration via a config.ini file.

  1. Deploy Selfoss using Docker Compose:

docker-compose up -d

After running this command, Selfoss will be accessible at http://<your_server_ip>:8080.

πŸš€ Manual Installation

For those who prefer a manual installation approach on a Linux server, follow these steps:

  1. Install necessary dependencies:

sudo apt update

sudo apt install -y apache2 php libapache2-mod-php php-sqlite3 unzip wget

  1. Download and extract Selfoss:

wget https://github.com/SSilence/selfoss/releases/latest/download/selfoss.zip

unzip selfoss.zip -d /var/www/selfoss

  1. Set permissions and configure Apache:

sudo chown -R www-data:www-data /var/www/selfoss

sudo chmod -R 755 /var/www/selfoss

  1. Enable Apache modules and restart:

sudo a2enmod rewrite

sudo systemctl restart apache2

Selfoss should now be accessible via your server's IP address.

Configuring Nginx as a Reverse Proxy

🌐 Nginx Configuration

To use Nginx as a reverse proxy for Selfoss:

  1. Create an Nginx server block file:

sudo nano /etc/nginx/sites-available/selfoss

Add the following configuration:


server {

listen 80;

server_name example.com;

location / {

proxy_pass http://localhost:8080;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}

}

  1. Enable the configuration and restart Nginx:

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

sudo nginx -t

sudo systemctl reload nginx

πŸ”’ SSL/TLS Setup

To secure Selfoss with SSL using Let’s Encrypt:

  1. Install Certbot:

sudo apt install -y certbot python3-certbot-nginx

  1. Generate and apply an SSL certificate:

sudo certbot --nginx -d example.com

  1. Automate certificate renewal:

sudo systemctl enable certbot.timer

Logging and Debugging Selfoss

πŸ—ƒοΈ Enabling Debug Logs

To enable debug-level logging in Selfoss:

  1. Edit the config.ini file in your Selfoss directory:

nano /path/to/selfoss/config.ini

  1. Add or modify the following line:

log_level = DEBUG

πŸ“„ Viewing Logs

If you are using Docker, view logs with:


docker logs -f selfoss

For manual installations, check logs in the data/log directory:


tail -f /var/www/selfoss/data/log/selfoss.log

πŸ› οΈ Troubleshooting Common Issues

Inspect logs for specific errors such as database connection failures. For example, if you encounter a SQLite permission error, ensure the data directory is writable:


sudo chmod -R 755 /var/www/selfoss/data

Backup and Restore

πŸ—‚οΈ File-Based Backups

Backup the Selfoss configuration and data files:


tar -czvf selfoss_backup.tar.gz /path/to/selfoss/config.ini /path/to/selfoss/data

πŸ”„ Database Backups

If Selfoss uses SQLite, backup the database with:


cp /path/to/selfoss/data/sqlite.db /path/to/backup/sqlite.db

Restore the database by copying the backup file back to its original location.

πŸ“… Automated Backup Scripts

Set up automated backups using cron:

  1. Create a backup script:

nano backup_selfoss.sh

Add the following:


#!/bin/bash

tar -czvf /path/to/backup/selfoss_$(date +%F).tar.gz /path/to/selfoss/data

  1. Make the script executable and schedule it via cron:

chmod +x backup_selfoss.sh

crontab -e

Add a daily backup task:


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

Updating and Upgrading Selfoss

⬆️ Updating Docker Images

To update Selfoss when using Docker:

  1. Pull the latest image:

docker-compose pull selfoss

  1. Restart the container:

docker-compose up -d

πŸ› οΈ Manual Updates

For manual installations, download the latest version and replace the existing files:


wget https://github.com/SSilence/selfoss/releases/latest/download/selfoss.zip

unzip -o selfoss.zip -d /var/www/selfoss

Then restart your web server:


sudo systemctl restart apache2

Leveraging Selfoss’s Unique Features

πŸ”§ Enabling APIs

To enable the Selfoss API:

  1. Edit the config.ini file:

api_enabled = true

  1. Use the API to fetch items with curl:

curl http://example.com/api/items

🌟 Advanced Configurations

To customize how feeds are updated, modify the config.ini file:


sources_update_interval = 3600

This example sets the feed update interval to one hour.

Wrapping Up

By following this guide, you’ve successfully deployed, configured, and secured Selfoss on your server. With its powerful features and ease of customization, Selfoss is a perfect solution for anyone looking to self-host a personal RSS feed aggregator. Now it’s time to explore APIs, advanced configurations, and backups to make the most out of your Selfoss deployment!

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.