How to install and configure JellyStat on a Swizzin server
JellyStat is a web-based statistics and monitoring tool for Jellyfin. It provides a dashboard with information about the server, the libraries, the users, and the playback activity. In this guide, we will install JellyStat via Docker on a Swizzin server.
The first step is to setup a subdomain for JellyStat jellystat.example.com and point it to the server's IP address. You can do this by adding an A record in your DNS provider. JellyStat does not currently support a base url thus example.com/jellystat is not possible.
Next, SSH into your server and install Docker and Docker Compose. You can do this by running the following commands:
# Check if Docker is already installed and if it is, skip to the next step
docker --version
# Docker not installed, grab the convenience script and execute it
curl -fsSL https://get.docker.com -o get-docker.sh
sh ./get-docker.shCreate a new directory for JellyStat and navigate to it:
mkdir -p /opt/jellystat
cd /opt/jellystatCreate a new file called docker-compose.yml and paste the following content:
version: '3'
services:
jellystat-db:
image: postgres:15.2
environment:
POSTGRES_DB: 'jfstat'
POSTGRES_USER: postgres
POSTGRES_PASSWORD: REPLACE_ME
volumes:
- ./postgres-data:/var/lib/postgresql/data # Mounting the volume
jellystat:
image: cyfershepard/jellystat:latest
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: REPLACE_ME
POSTGRES_IP: jellystat-db
POSTGRES_PORT: 5432
JWT_SECRET: 'REPLACE_ME_WITH_RANDOM_STRING'
ports:
- "127.0.0.1:3000:3000" #Server Port
volumes:
- ./backup-data:/app/backend/backup-data # Mounting the volume
depends_on:
- jellystat-db
restart: unless-stopped
networks:
default:Replace REPLACE_ME with a random string for the POSTGRES_PASSWORD, ensuring they both match. Do the same for REPLACE_ME_WITH_RANDOM_STRING. You can generate a cryptographically secure pseudo random string using the following command:
openssl rand 64 | openssl enc -A -base64The port 3000 may be in use by another service. You can change it to another port if needed. Make sure to only update the first port number after 127.0.0.1. We're mapping one port to another, so the second port should remain the same.
To check if the port is in use, run the following command:
netstat -tulnp | grep 3000Save the file and run the following command to start JellyStat:
docker-compose up -dJellyStat should now be running and only accessible from localhost, you can verify this by visiting http://example.com:3000 and getting no response. We now need to setup a reverse proxy to make it accessible from the internet and secure it with SSL.
First step is to generate a new SSL certificate using LetsEncrypt. Run the following command:
box install letsencryptEnter the domain jellystat.example.com when prompted. Answer n to Do you want to apply this certificate to your swizzin default conf? and also choose the correct option for Is your DNS managed by CloudFlare?. Once the certificate is generated, we can proceed to setup the reverse proxy.
Create a new file called jellystat.example.com in /etc/nginx/sites-available/ and paste the following content:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name jellystat.example.com;
ssl_certificate /etc/nginx/ssl/jellystat.example.com/fullchain.pem;
ssl_certificate_key /etc/nginx/ssl/jellystat.example.com/key.pem;
include snippets/ssl-params.conf;
client_max_body_size 40M;
server_tokens off;
root /srv/;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_pass_request_headers on;
proxy_set_header Host $proxy_host;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Protocol $scheme;
proxy_set_header X-Forwarded-Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Ssl on;
add_header X-Frame-Options "ALLOWALL";
proxy_redirect off;
proxy_buffering off;
auth_basic off;
}
}Replace jellystat.example.com with your domain and save the file. Also be sure to change the port if 3000 was already in use. Now, create a symbolic link to the sites-enabled directory:
ln -s /etc/nginx/sites-available/jellystat.example.com /etc/nginx/sites-enabled/jellystat.example.comFinally, test nginx and reload to apply the changes:
nginx -t
# If the test is successful, reload nginx
nginx -s reloadJellyStat should now be accessible at https://jellystat.example.com 🎉
To configure JellyStat, navigate to https://jellystat.example.com and follow the on-screen instructions. You will be prompted to create an admin account and connect JellyStat to your Jellyfin server. I had to use https://example.com/jellyfin as the Jellyfin URL to get it to work. To generate the API key, navigate to https://example.com/jellyfin/web/index.html#/dashboard/keys. Administration > Dashboard > API Keys. Click on the + sign to create a new key and copy it to JellyStat.
You may want to force a complete sync by clicking on Settings then Start under Tasks next to Complete Sync with Jellyfin. If you previously used the Playback Reporting Plugin for Jellyfin you can also import that data from here.
Enjoy!
To add JellyStat to the Swizzin panel, open the file /opt/swizzin/core/custom/profiles.py and add the following lines:
class jellystat_meta:
name = "jellystat"
pretty_name = "JellyStat"
urloverride = "https://jellystat.example.com"Next, we want to download the JellyStat logo and place it in the correct directory. Run the following commands:
wget -O /opt/swizzin/static/img/apps/jellystat.png https://raw.githubusercontent.com/CyferShepard/Jellystat/main/src/pages/images/icon-b-512.pngFinally, run the following commands to apply the changes:
touch /install/.jellystat.lock
systemctl restart panelHint: You can remove the /install/.jellystat.lock file to remove JellyStat from the panel, this is how Swizzin knows which apps are installed.