Skip to content

Production-ready deployment scripts for CTFd on Azure Ubuntu VMs with automated SSL, Docker management, and comprehensive error handling.

License

Notifications You must be signed in to change notification settings

therealcybermattlee/CTFd-Azure-Deployment-Scripts

Repository files navigation

CTFd Azure Deployment Scripts

License: MIT CTFd Docker Ubuntu

Production-ready deployment scripts for CTFd on Azure Ubuntu VMs with automated SSL, Docker management, and comprehensive error handling.

πŸš€ Features

  • One-Command Installation - Fully automated CTFd deployment
  • Azure Optimized - Handles Azure VM-specific Docker and networking issues
  • SSL/TLS Automation - Let's Encrypt integration with auto-renewal
  • Error Recovery - Intelligent error handling and automatic fixes
  • Database Management - Automatic credential generation and recovery
  • Complete Lifecycle - Install, uninstall, backup, and maintenance scripts
  • Production Ready - Nginx reverse proxy, security hardening, and monitoring

πŸ“‹ Prerequisites

  • Azure Ubuntu VM (22.04 LTS or newer)
  • Minimum 2 vCPUs and 4GB RAM
  • Domain name pointing to your VM's public IP
  • Ports 80, 443, and 22 open in Azure NSG

πŸ”§ Quick Start

1. Clone the Repository

git clone https://github.com/therealcybermattlee/ctfd-azure-deploy.git
cd ctfd-azure-deploy

2. Configure Your Domain

Edit install-ctfd.sh and update:

DOMAIN="your-domain.com"  # Replace with your actual domain
EMAIL="admin@your-domain.com"  # For Let's Encrypt notifications

3. Run Installation

chmod +x install-ctfd.sh
sudo ./install-ctfd.sh

The script will:

  • Install and configure Docker
  • Set up CTFd with MariaDB and Redis
  • Configure Nginx as reverse proxy
  • Obtain SSL certificate from Let's Encrypt
  • Create management scripts

πŸ“ Repository Structure

ctfd-azure-deploy/
β”œβ”€β”€ install-ctfd.sh      # Main installation script
β”œβ”€β”€ uninstall-ctfd.sh    # Complete uninstall script
β”œβ”€β”€ README.md            # This file
β”œβ”€β”€ LICENSE              # MIT License
β”œβ”€β”€ CONTRIBUTING.md      # Contribution guidelines
β”œβ”€β”€ docs/
β”‚   β”œβ”€β”€ TROUBLESHOOTING.md
β”‚   β”œβ”€β”€ AZURE-SETUP.md
β”‚   └── SSL-SETUP.md
└── .github/
    └── ISSUE_TEMPLATE/
        β”œβ”€β”€ bug_report.md
        └── feature_request.md

πŸ› οΈ Management Scripts

After installation, the following scripts are created in ~/CTFd/:

Script Purpose
start-ctfd.sh Start CTFd containers
stop-ctfd.sh Stop CTFd containers
restart-ctfd.sh Restart CTFd containers
logs-ctfd.sh View real-time logs
backup-ctfd.sh Create backup
health-ctfd.sh Check service health
fix-ctfd.sh Auto-fix common issues

πŸ” Security Features

  • Automatic secure password generation
  • SSL/TLS with Let's Encrypt
  • Nginx security headers
  • Docker security best practices
  • Automated backups (daily at 2 AM)
  • Isolated Docker networks

πŸ”„ Uninstallation

Three uninstall modes available:

sudo ./uninstall-ctfd.sh
  1. Remove CTFd only - Keeps Docker installed
  2. Remove CTFd and containers - Keeps Docker installation
  3. Complete removal - Removes everything including Docker

πŸ› Troubleshooting

Common Issues

Docker Won't Start

sudo groupadd -f docker
sudo usermod -aG docker $USER
sudo systemctl restart docker

Database Connection Failed

cd ~/CTFd
docker compose down -v
sudo rm -rf data/mysql/*
docker compose up -d

SSL Certificate Issues

Ensure DNS is properly configured:

# Check DNS
dig +short your-domain.com

# Manual SSL setup
sudo certbot --nginx -d your-domain.com

See docs/TROUBLESHOOTING.md for detailed solutions.

πŸ“Š System Requirements

Minimum

  • 2 vCPUs
  • 4GB RAM
  • 20GB Storage
  • Ubuntu 22.04 LTS

Recommended

  • 4 vCPUs
  • 8GB RAM
  • 50GB Storage
  • Ubuntu 22.04/24.04 LTS

🌐 Azure Network Security Group

Required inbound rules:

Port Protocol Purpose
22 TCP SSH Access
80 TCP HTTP Traffic
443 TCP HTTPS Traffic

πŸ“ Environment Variables

The installation creates .env with:

  • SECRET_KEY - CTFd secret key
  • MYSQL_ROOT_PASSWORD - Database root password
  • DB_PASSWORD - CTFd database password
  • DOMAIN - Your domain name

⚠️ Keep .env secure and never commit to git!

🀝 Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

πŸ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

πŸ™ Acknowledgments

πŸ“§ Support

πŸ”„ Version History

  • v1.0.0 (2025-09-02)
    • Initial release
    • Full Azure VM support
    • Automated SSL setup
    • Complete error handling

πŸ—οΈ Roadmap

  • Support for multiple CTFd instances
  • Kubernetes deployment option
  • AWS/GCP support
  • Automated challenge deployment
  • Monitoring dashboard integration

Made with ❀️ for the CTF community

About

Production-ready deployment scripts for CTFd on Azure Ubuntu VMs with automated SSL, Docker management, and comprehensive error handling.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages