diff --git a/.env.production b/.env.production index d3197c5..52ae2e9 100644 --- a/.env.production +++ b/.env.production @@ -1,20 +1,9 @@ USER_ID=1000 -# Index GUI -TORRUST_INDEX_GUI_API_BASE_URL='https://index.torrust-demo.com/api/v1' -NITRO_HOST=0.0.0.0 -NITRO_PORT=3000 - -# Index -TORRUST_INDEX_CONFIG_TOML= -TORRUST_INDEX_API_CORS_PERMISSIVE=false -TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER='MyClaimTokenPepper' -TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN='MyAccessToken' - # Tracker TORRUST_TRACKER_CONFIG_TOML= TORRUST_TRACKER_CONFIG_OVERRIDE_HTTP_API__ACCESS_TOKENS__ADMIN='MyAccessToken' # Grafana GF_SECURITY_ADMIN_USER=admin -GF_SECURITY_ADMIN_PASSWORD=admin \ No newline at end of file +GF_SECURITY_ADMIN_PASSWORD=admin diff --git a/README.md b/README.md index 91f1c40..e90b0f8 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ -# Torrust Demo +# Torrust Tracker Demo -This repo contains all the configuration needed to run the live Torrust demo. - -Live demo: . +This repo contains all the configuration needed to run the live Torrust Tracker demo. It's also used to track issues in production. +> IMPORTANT: We are in the process of [splitting the Torrust Demo repo into two repos](https://github.com/torrust/torrust-demo/issues/79). This will allow us to deploy both services independently and it would make easier for users who only want to setup the tracker to re-use this setup. The content of this repo may change drastically in the future. + ## Demo tracker - HTTP Tracker: diff --git a/compose.yaml b/compose.yaml index bbafda0..b8d7d9b 100644 --- a/compose.yaml +++ b/compose.yaml @@ -41,57 +41,6 @@ services: - tracker - grafana - index-gui: - image: torrust/index-gui:develop - container_name: index-gui - tty: true - restart: unless-stopped - environment: - - USER_ID=${USER_ID} - - NUXT_PUBLIC_API_BASE=${TORRUST_INDEX_GUI_API_BASE_URL:-http://localhost:3001/v1} - - NITRO_HOST=${NITRO_HOST:-0.0.0.0} - - NITRO_PORT=${NITRO_PORT:-3000} - networks: - - frontend_network - ports: - - 3000:3000 - volumes: - - ./storage/index-gui/log:/var/log/torrust/index-gui:Z - logging: - options: - max-size: "10m" - max-file: "10" - depends_on: - - index - - tracker - - index: - image: torrust/index:develop - container_name: index - tty: true - restart: unless-stopped - environment: - - USER_ID=${USER_ID} - - TORRUST_INDEX_DATABASE=${TORRUST_INDEX_DATABASE:-sqlite3} - - TORRUST_INDEX_DATABASE_DRIVER=${TORRUST_INDEX_DATABASE_DRIVER:-sqlite3} - - TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN=${TORRUST_INDEX_CONFIG_OVERRIDE_TRACKER__TOKEN:-MyAccessToken} - - TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER=${TORRUST_INDEX_CONFIG_OVERRIDE_AUTH__USER_CLAIM_TOKEN_PEPPER:-MaxVerstappenWC2021} - - TORRUST_INDEX_API_CORS_PERMISSIVE=${TORRUST_INDEX_API_CORS_PERMISSIVE:-true} - networks: - - backend_network - ports: - - 3001:3001 - volumes: - - ./storage/index/lib:/var/lib/torrust/index:Z - - ./storage/index/log:/var/log/torrust/index:Z - - ./storage/index/etc:/etc/torrust/index:Z - logging: - options: - max-size: "10m" - max-file: "10" - depends_on: - - tracker - grafana: image: grafana/grafana:11.4.0 container_name: grafana diff --git a/docs/backups.md b/docs/backups.md index b9451b2..014a8f1 100644 --- a/docs/backups.md +++ b/docs/backups.md @@ -1,10 +1,10 @@ # Backups -## Backup Index Database +## Backup Tracker Database ```bash -cd /home/torrust/github/torrust/torrust-demo/ -./share/bin/index-db-backup.sh +cd /home/torrust/github/torrust/torrust-tracker-demo/ +./share/bin/tracker-db-backup.sh ``` ## Check Backups Crontab Configuration @@ -26,7 +26,7 @@ total 26618268 -rwxr-x--- 1 root root 2342912 May 12 04:00 backup_2025-05-12_04-00-01.db ``` -YOu can also check the script output with: +You can also check the script output with: ```bash tail /var/log/cron.log diff --git a/docs/deployment.md b/docs/deployment.md index 31240e3..f7d2848 100644 --- a/docs/deployment.md +++ b/docs/deployment.md @@ -1,7 +1,7 @@ # Deployment 1. SSH into the server. -2. Execute the deployment script: `./bin/deploy-torrust-demo.com.sh`. +2. Execute the deployment script: `./bin/deploy-torrust-tracker-demo.com.sh`. 3. Execute the smoke tests: ```console diff --git a/docs/firewall.md b/docs/firewall.md index b175fe4..80749be 100644 --- a/docs/firewall.md +++ b/docs/firewall.md @@ -1,6 +1,6 @@ # Firewall -We are using a Digital Ocean Firewall. +We are using a Hetzner Firewall. ![Firewall Rules](./do-firewall-configuration.png) diff --git a/docs/qbittorrent/torrust.py b/docs/qbittorrent/torrust.py deleted file mode 100644 index ae0fb33..0000000 --- a/docs/qbittorrent/torrust.py +++ /dev/null @@ -1,86 +0,0 @@ -#VERSION: 1.00 -# AUTHORS: -# Hung Nguyen (hungnt.code@proton.me) -# LICENSING INFORMATION - -from html.parser import HTMLParser -from urllib.parse import urlencode -from helpers import download_file, retrieve_url -from novaprinter import prettyPrinter -# some other imports if necessary -import json -from datetime import datetime - -class torrust(object): - """ - `url`, `name`, `supported_categories` should be static variables of the engine_name class, - otherwise qbt won't install the plugin. - - `url`: The URL of the search engine. - `name`: The name of the search engine, spaces and special characters are allowed here. - `supported_categories`: What categories are supported by the search engine and their corresponding id, - possible categories are ('all', 'anime', 'books', 'games', 'movies', 'music', 'pictures', 'software', 'tv'). - """ - - url = 'https://index.torrust-demo.com' - name = 'Torrust' - - # Torrust categories API: https://index.torrust-demo.com/api/v1/category - # Map qBittorrent categories to Torrust categories - supported_categories = { - 'all': '', - 'movies': 'movies', - 'tv': 'tv shows', - 'games': 'games', - 'music': 'music', - 'software': 'software', - 'books': ['audiobook', 'paper'] - } - - def __init__(self): - """ - Some initialization - """ - - def download_torrent(self, info): - """ - Providing this function is optional. - It can however be interesting to provide your own torrent download - implementation in case the search engine in question does not allow - traditional downloads (for example, cookie-based download). - """ - print(download_file(info)) - - # DO NOT CHANGE the name and parameters of this function - # This function will be the one called by nova2.py - def search(self, what, cat='all'): - """ - Here you can do what you want to get the result from the search engine website. - Everytime you parse a result line, store it in a dictionary - and call the prettyPrint(your_dict) function. - - `what` is a string with the search tokens, already escaped (e.g. "Ubuntu+Linux") - `cat` is the name of a search category in ('all', 'anime', 'books', 'games', 'movies', 'music', 'pictures', 'software', 'tv') - """ - base_url = 'https://index.torrust-demo.com/api/v1/torrents?%s' - category_value = self.supported_categories[cat] - categories = ','.join(category_value) if isinstance(category_value, list) else category_value - params = {'search': what, 'categories': categories} - response = retrieve_url(base_url % urlencode(params)) - - json_data = json.loads(response) - results = json_data['data']['results'] - - for result in results: - info_hash = result['info_hash'] - torrent_info = { - 'link': f"magnet:?xt=urn:btih:{info_hash}", - 'name': result['title'], - 'size': result['file_size'], - 'seeds': result['seeders'], - 'leech': result['leechers'], - 'engine_url': self.url, - 'desc_link': f"{self.url}/torrent/{info_hash}", - 'pub_date': int(datetime.strptime(result['date_uploaded'], '%Y-%m-%d %H:%M:%S').timestamp()) - } - prettyPrinter(torrent_info) \ No newline at end of file diff --git a/docs/setup.md b/docs/setup.md index 391d009..799a5ce 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -4,10 +4,10 @@ Follow instructions on [Deploying Torrust To Production](https://torrust.com/blo You need to also enable a [firewall](./docs/firewall.md). -The application is located in the directory: `/home/torrust/github/torrust/torrust-demo`. +The application is located in the directory: `/home/torrust/github/torrust/torrust-tracker-demo`. To run docker compose commands you need to cd to the app dir: ```console -cd /home/torrust/github/torrust/torrust-demo +cd /home/torrust/github/torrust/torrust-tracker-demo ``` diff --git a/project-words.txt b/project-words.txt index 8204b8d..79373c1 100644 --- a/project-words.txt +++ b/project-words.txt @@ -9,6 +9,7 @@ nosniff NUXT privkey publickey +rwxr SAMEORIGIN secp webroot diff --git a/share/bin/deploy-torrust-demo.com.sh b/share/bin/deploy-torrust-tracker-demo.com.sh similarity index 70% rename from share/bin/deploy-torrust-demo.com.sh rename to share/bin/deploy-torrust-tracker-demo.com.sh index e435e0f..9a40b8f 100755 --- a/share/bin/deploy-torrust-demo.com.sh +++ b/share/bin/deploy-torrust-tracker-demo.com.sh @@ -2,7 +2,7 @@ # Update the demo by updating the containers -cd /home/torrust/github/torrust/torrust-demo || exit +cd /home/torrust/github/torrust/torrust-tracker-demo || exit docker compose pull docker compose down docker compose up --build --detach diff --git a/share/bin/index-db-backup.sh b/share/bin/index-db-backup.sh deleted file mode 100755 index e30a813..0000000 --- a/share/bin/index-db-backup.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -# Backup the Index SQLite database - -# Define the directory where backups will be stored -BACKUP_DIR="/home/torrust/backups" - -# Define the SQLite database file's path -DATABASE_FILE="/home/torrust/github/torrust/torrust-demo/storage/index/lib/database/sqlite3.db" - -# Create a timestamped backup filename -BACKUP_FILE="$BACKUP_DIR/backup_$(date +%Y-%m-%d_%H-%M-%S).db" - -# Copy the SQLite database file to create a backup -cp $DATABASE_FILE "$BACKUP_FILE" - -# Find and remove backups older than 7 days -find $BACKUP_DIR -type f -name "backup_*.db" -mtime +7 -exec rm -f {} \; - diff --git a/share/bin/install.sh b/share/bin/install.sh index 81b95b4..b21c8d4 100755 --- a/share/bin/install.sh +++ b/share/bin/install.sh @@ -21,23 +21,6 @@ fi mkdir -p ./storage/certbot/etc mkdir -p ./storage/certbot/lib -## Index - -# Generate the Index sqlite database directory and file if it does not exist -mkdir -p ./storage/index/lib/database - -if ! [ -f "./storage/index/lib/database/sqlite3.db" ]; then - echo "Creating index database: './storage/index/lib/database/sqlite3.db'" - sqlite3 "./storage/index/lib/database/sqlite3.db" "VACUUM;" -fi - -mkdir -p ./storage/index/etc - -if ! [ -f "./storage/index/etc/index.prod.container.sqlite3.toml" ]; then - echo "Crating index configuration: './storage/index/etc/index.toml'" - cp ./share/container/default/config/index.prod.container.sqlite3.toml ./storage/index/etc/index.toml -fi - ## Tracker # Generate the Tracker sqlite database directory and file if it does not exist diff --git a/share/bin/ssl_renew.sh b/share/bin/ssl_renew.sh index 38b6758..4674a33 100755 --- a/share/bin/ssl_renew.sh +++ b/share/bin/ssl_renew.sh @@ -3,7 +3,7 @@ COMPOSE="/usr/bin/docker compose --ansi never" DOCKER="/usr/bin/docker" -cd /home/torrust/github/torrust/torrust-demo || exit +cd /home/torrust/github/torrust/torrust-tracker-demo || exit # Run this just for testing purposes #$COMPOSE run certbot renew --dry-run && $COMPOSE kill -s SIGHUP proxy diff --git a/share/bin/tracker-db-backup.sh b/share/bin/tracker-db-backup.sh index 51f5307..a3d6b6a 100755 --- a/share/bin/tracker-db-backup.sh +++ b/share/bin/tracker-db-backup.sh @@ -6,7 +6,7 @@ BACKUP_DIR="/home/torrust/backups" # Define the SQLite database file's path -DATABASE_FILE="/home/torrust/github/torrust/torrust-demo/storage/tracker/lib/database/sqlite3.db" +DATABASE_FILE="/home/torrust/github/torrust/torrust-tracker-demo/storage/tracker/lib/database/sqlite3.db" # Create a timestamped backup filename BACKUP_FILE="$BACKUP_DIR/tracker_backup_$(date +%Y-%m-%d_%H-%M-%S).db" diff --git a/share/container/default/config/crontab.conf b/share/container/default/config/crontab.conf index 6075511..82547cf 100644 --- a/share/container/default/config/crontab.conf +++ b/share/container/default/config/crontab.conf @@ -1,2 +1,2 @@ -0 12 * * * /home/torrust/github/torrust/torrust-demo/share/bin/ssl_renew.sh >> /var/log/cron.log 2>&1 -0 * * * * /home/torrust/github/torrust/torrust-demo/share/bin/index-db-backup.sh >> /var/log/cron.log 2>&1 +0 12 * * * /home/torrust/github/torrust/torrust-tracker-demo/share/bin/ssl_renew.sh >> /var/log/cron.log 2>&1 +0 * * * * /home/torrust/github/torrust/torrust-tracker-demo/share/bin/tracker-db-backup.sh >> /var/log/cron.log 2>&1 diff --git a/share/container/default/config/index.prod.container.sqlite3.toml b/share/container/default/config/index.prod.container.sqlite3.toml deleted file mode 100644 index f7d2c87..0000000 --- a/share/container/default/config/index.prod.container.sqlite3.toml +++ /dev/null @@ -1,25 +0,0 @@ -[metadata] -app = "torrust-index" -purpose = "configuration" -schema_version = "2.0.0" - -[website.demo] - -[logging] -threshold = "info" - -[tracker] -api_url = "http://tracker:1212" -listed = false -private = false -url = "udp://tracker.torrust-demo.com:6969" - -[database] -connect_url = "sqlite:///var/lib/torrust/index/database/sqlite3.db?mode=rwc" - -[mail.smtp] -port = 1025 -server = "mailcatcher" - -[registration] -[registration.email] \ No newline at end of file diff --git a/share/container/default/config/nginx.conf b/share/container/default/config/nginx.conf index 4aa596b..be7bf76 100644 --- a/share/container/default/config/nginx.conf +++ b/share/container/default/config/nginx.conf @@ -1,39 +1,3 @@ -server -{ - listen 80; - listen [::]:80; - - root /var/www/html; - index index.html index.htm index.nginx-debian.html; - - server_name index.torrust-demo.com; - - error_log /var/log/nginx/error.log debug; - - location /api/v1/proxy - { - rewrite ^ $request_uri; - rewrite ^/api(/.*) $1 break; - proxy_pass http://index:3001; - } - - location ^~/api/ - { - proxy_pass http://index:3001/; - } - - location / - { - proxy_pass http://index-gui:3000; - } - - location ~ /.well-known/acme-challenge - { - allow all; - root /var/www/html; - } -} - server { listen 80; @@ -83,83 +47,6 @@ server } } -#server -#{ -# listen 443 ssl http2; -# listen [::]:443 ssl http2; -# server_name index.torrust-demo.com; -# -# error_log /var/log/nginx/error.log debug; -# merge_slashes off; -# server_tokens off; -# -# ssl_certificate /etc/letsencrypt/live/index.torrust-demo.com-0001/fullchain.pem; -# ssl_certificate_key /etc/letsencrypt/live/index.torrust-demo.com-0001/privkey.pem; -# -# ssl_buffer_size 8k; -# -# ssl_dhparam /etc/ssl/certs/dhparam-2048.pem; -# -# ssl_protocols TLSv1.2; -# ssl_prefer_server_ciphers on; -# -# ssl_ciphers ECDH+AESGCM:ECDH+AES256:ECDH+AES128:DH+3DES:!ADH:!AECDH:!MD5; -# -# ssl_ecdh_curve secp384r1; -# ssl_session_tickets off; -# -# ssl_stapling on; -# ssl_stapling_verify on; -# resolver 8.8.8.8; -# -# error_log /var/log/nginx/error.log debug; -# -# location /api/v1/proxy -# { -# rewrite ^ $request_uri; -# rewrite ^/api(/.*) $1 break; -# try_files $uri @index; -# } -# -# location ^~/api/ -# { -# rewrite ^/api/(.*)$ /$1 break; -# try_files $uri @index; -# } -# -# location / -# { -# try_files $uri @index-gui; -# } -# -# location @index -# { -# proxy_pass http://index:3001; -# add_header X-Frame-Options "SAMEORIGIN" always; -# add_header X-XSS-Protection "1; mode=block" always; -# add_header X-Content-Type-Options "nosniff" always; -# add_header Referrer-Policy "no-referrer-when-downgrade" always; -# add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; -# #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; -# # enable strict transport security only if you understand the implications -# } -# -# location @index-gui -# { -# proxy_pass http://index-gui:3000; -# add_header X-Frame-Options "SAMEORIGIN" always; -# add_header X-XSS-Protection "1; mode=block" always; -# add_header X-Content-Type-Options "nosniff" always; -# add_header Referrer-Policy "no-referrer-when-downgrade" always; -# add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always; -# #add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; -# # enable strict transport security only if you understand the implications -# } -# -# root /var/www/html; -# index index.html index.htm index.nginx-debian.html; -#} - #server #{ # listen 443 ssl http2; diff --git a/share/grafana/dashboards/README.md b/share/grafana/dashboards/README.md index 7a57d5b..ba40bec 100644 --- a/share/grafana/dashboards/README.md +++ b/share/grafana/dashboards/README.md @@ -3,3 +3,4 @@ Backups containing the dashboard configuration for Grafana. - `stats.json`: The dashboard using metrics from the `stats` endpoint: . +- `metrics.json`: The dashboard using metrics from the `metrics` endpoint: .