# Installation ## Prérequis - VPS Linux avec Python 3.8+ - nginx - Certbot --- ## 1. Déployer le serveur Python ```bash sudo mkdir -p /var/www/torrent-indicator sudo cp scrape_server.py /var/www/torrent-indicator/ ``` ### Activer le service systemd ```bash sudo cp torrent-scrape.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable --now torrent-scrape ``` Vérifier : ```bash sudo systemctl status torrent-scrape # ● torrent-scrape.service - Torrent Tracker Scrape Server # Active: active (running) ``` --- ## 2. Obtenir le certificat SSL ```bash sudo certbot certonly --nginx -d torrent-api.monsite.com ``` --- ## 3. Configurer nginx Ajouter dans `/etc/nginx/sites-available/votresite` : ```nginx server { server_name torrent-api.monsite.com; location / { proxy_pass http://127.0.0.1:8765/; proxy_set_header Host $host; 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_read_timeout 15s; } listen 443 ssl; ssl_certificate /etc/letsencrypt/live/torrent-api.monsite.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/torrent-api.monsite.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; } server { if ($host = torrent-api.monsite.com) { return 301 https://$host$request_uri; } listen 80; server_name torrent-api.monsite.com; return 404; } ``` ```bash sudo nginx -t && sudo nginx -s reload ``` --- ## 4. Vérifier l'API publique ```bash curl "https://torrent-api.monsite.com/?hash=3b245504cf5f11bbdbe1201cea6a6bf45aee1bc0" ``` Réponse attendue : ```json { "seeders": 1234, "leechers": 56, "health": "excellent", "popularity": "popular", "sources": 4 } ``` --- ## Configuration Les paramètres se trouvent en haut de `scrape_server.py` : | Variable | Défaut | Description | |---|---|---| | `HOST` | `127.0.0.1` | Interface d'écoute | | `PORT` | `8765` | Port du serveur | | `TIMEOUT` | `7` | Timeout par tracker (secondes) | | `CACHE_TTL` | `300` | Durée du cache (secondes) | | `TRACKERS` | *(liste)* | Trackers HTTP interrogés | Après modification, redémarrer le service : ```bash sudo systemctl restart torrent-scrape ```