Step by step guide on hosting a CTF for FREE
CTFd is an easy to setup CTF platform which is open-source. This writeup focuses on setting up a CTF hosting platform as quickly as possible using CTFd.
First we need a machine that can house the CTFd framework.
1. Machine for CTFd framework
We will use digitalocean to create our free machine.
- Register a new account on digitalocean using this link. This will give you a free $200 credit for a 60-day period.
- Create a droplet
* Ubuntu x64, 8GB-4Intel vCPU, 160GB SSD, 5TB Transfer
2. Install CTFd framework on Droplet
- Power on the droplet (if not already on) and access console to login as root.
- Once logged in, issue the following commands:
At this point, navigate to localhost:8000 or dropletIP:8000 and the CTFd platform will be running. But the CTFd will be hosted on http and not https.
3. HTTP to HTTPS
3.1. Link droplet to a domain name
In order to setup an SSL certificate a domain name is required. We will use free Cloudns hosting to point IP address of droplet to a .cloudns.ph or .cloudns.nz domain.
To connect IP address to a cloudns. domain follow below steps:
- Signup on cloudns.net using the link
- Go to Dashboard.
- Under DNS hosting, click on "create zone"
- Choose a domain name and click "Register"
- Once created click on your domain and add your droplet IP in the "A" section
Wait for the records to be updated. Then visit yourdomain and CTFd will be running on http.
3.2. Create Free SSL certificate with acme.sh
Install acme.sh client on the droplet using following command:
Now using the acme.sh create an ssl certificate for yourdomain. We will be using DNS manual mode of acme.sh client to do this:
- Issue the following command
You will get an output like below:
Certificates and private key will be created in the acme.sh folder under yourdomain subfolder.
3.3. Configure SSL in NGINX
Bring down the docker using docker-compose down.
- Copy the certificates and the private key created before to CTFd/conf/nginx/
- Modify volumes and ports section of docker-compose.yml file as below:
- Modify CTFd/conf/nginx/http.conf file as below:
Now bring the docker up using command docker-compose up (within CTFd directory)
Comments
Post a Comment