Complete Docker setup for RustChain node with nginx reverse proxy and optional SSL.
On a fresh Ubuntu 22.04 VPS:
# Clone the repository
git clone https://github.com/Scottcjn/Rustchain.git
cd Rustchain
# Start all services
docker-compose up -dThat's it! RustChain will be available at:
- HTTP: http://your-server-ip (via nginx)
- Direct: http://your-server-ip:8099 (bypass nginx)
-
rustchain-node (Python Flask application)
- Dashboard on port 8099
- SQLite database with persistent storage
- Automatic health checks and restarts
-
nginx (Reverse proxy)
- HTTP on port 80
- HTTPS on port 443 (when SSL enabled)
- Load balancing and SSL termination
All data is stored in Docker volumes:
rustchain-data: SQLite database (rustchain_v2.db)rustchain-downloads: Downloaded files
Data persists across container restarts and updates.
Copy the example environment file:
cp .env.example .envEdit .env to customize:
- Port mappings
- SSL settings
- Resource limits
- Logging levels
RUSTCHAIN_DASHBOARD_PORT=8099
NGINX_HTTP_PORT=80
NGINX_HTTPS_PORT=443
ENABLE_SSL=false
LOG_LEVEL=INFOGenerate certificates:
mkdir -p ssl
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \
-keyout ssl/key.pem -out ssl/cert.pem \
-subj "/CN=rustchain.local"# Install certbot
sudo apt-get install certbot
# Get certificate
sudo certbot certonly --standalone -d your-domain.com
# Copy certificates
mkdir -p ssl
sudo cp /etc/letsencrypt/live/your-domain.com/fullchain.pem ssl/cert.pem
sudo cp /etc/letsencrypt/live/your-domain.com/privkey.pem ssl/key.pem
sudo chown $USER:$USER ssl/*.pemEnable SSL in docker-compose.yml:
services:
nginx:
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
- ./ssl/cert.pem:/etc/nginx/ssl/cert.pem:ro
- ./ssl/key.pem:/etc/nginx/ssl/key.pem:roUpdate .env:
ENABLE_SSL=trueRestart:
docker-compose restart nginxdocker-compose up -ddocker-compose down# All services
docker-compose logs -f
# Specific service
docker-compose logs -f rustchain-node
docker-compose logs -f nginx# All services
docker-compose restart
# Specific service
docker-compose restart rustchain-nodegit pull origin main
docker-compose build --no-cache
docker-compose up -d# Check running containers
docker-compose ps
# Check node health
curl http://localhost:8099/health
# Check via nginx
curl http://localhost/health# Create backup directory
mkdir -p backups
# Backup database
docker cp rustchain-node:/rustchain/data/rustchain_v2.db \
backups/rustchain_v2_$(date +%Y%m%d_%H%M%S).db# Stop services
docker-compose down
# Restore database
docker volume create rustchain-data
docker run --rm -v rustchain-data:/data -v $(pwd)/backups:/backup \
alpine sh -c "cp /backup/rustchain_v2_YYYYMMDD_HHMMSS.db /data/rustchain_v2.db"
# Start services
docker-compose up -ddocker exec -it rustchain-node sqlite3 /rustchain/data/rustchain_v2.dbCheck logs:
docker-compose logs rustchain-nodeCheck if port is already in use:
sudo netstat -tulpn | grep :8099
sudo netstat -tulpn | grep :80Stop all containers and restart:
docker-compose down
docker-compose up -dFix volume permissions:
docker-compose down
docker volume rm rustchain-data rustchain-downloads
docker-compose up -dCheck health status:
docker inspect rustchain-node | grep -A 10 HealthView full logs:
docker logs rustchain-node --tail 100- OS: Ubuntu 22.04 LTS (or any Linux with Docker)
- RAM: 512 MB
- Disk: 2 GB free space
- CPU: 1 core
- OS: Ubuntu 22.04 LTS
- RAM: 1 GB
- Disk: 10 GB free space
- CPU: 2 cores
# Install Docker
curl -fsSL https://get.docker.com | sh
# Install Docker Compose (if not included)
sudo apt-get install docker-compose-plugin
# Add user to docker group
sudo usermod -aG docker $USERLog out and log back in for group changes to take effect.
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw allow 8099/tcp # Direct dashboard access (optional)
sudo ufw enablesudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
sudo iptables-save | sudo tee /etc/iptables/rules.v4- Set custom
.envconfiguration - Enable SSL with valid certificates
- Configure firewall rules
- Set up automated backups
- Configure log rotation
- Enable Docker auto-start:
sudo systemctl enable docker - Test health checks:
curl http://localhost/health - Monitor logs for errors
- Set up monitoring (optional: Prometheus, Grafana)
-
Always use SSL in production
- Use Let's Encrypt for free certificates
- Never expose unencrypted HTTP on public internet
-
Regular Backups
- Automate database backups daily
- Store backups off-site
-
Keep Updated
- Run
git pull && docker-compose build --no-cacheweekly - Monitor security advisories
- Run
-
Resource Limits
- Set memory and CPU limits in docker-compose.yml
- Monitor resource usage
-
Network Security
- Use UFW or iptables to restrict access
- Only expose necessary ports
- Consider using a VPN or SSH tunnel for admin access
- GitHub Issues: https://github.com/Scottcjn/Rustchain/issues
- Documentation: https://github.com/Scottcjn/Rustchain
- Community: Check the main README for community links
MIT License - See LICENSE file for details