Judge0 Installation & Running Document
Domain: judge.tr**klms.org
Server: AWS EC2 Ubuntu
Purpose: Deploy Judge0 code execution server with SSL using Nginx reverse proxy.
1. Server Requirements
Minimum recommended server:
Ubuntu 22.04 LTS
2 vCPU
4 GB RAM minimum
40 GB SSD minimum
Recommended for live usage:
Ubuntu 22.04 LTS
2 vCPU or more
8 GB RAM
80 GB SSD
2. Required Ports in AWS Security Group
Open these ports in EC2 Security Group:
22 SSH Your IP only
80 HTTP 0.0.0.0/0
443 HTTPS 0.0.0.0/0
Do not expose Judge0 port 2358 publicly.
Judge0 will run internally on:
http://127.0.0.1:2358
Public users will access:
https://judge.tr**klms.org
3. DNS Setup
In the domain DNS panel, create an A record:
Type: A
Name: judge
Value: EC2_PUBLIC_IP
TTL: Auto
Example:
judge.tr**klms.org -> Your EC2 public IP
4. Update Server Packages
Run:
sudo apt update
sudo apt upgrade -y
Install basic required packages:
sudo apt install -y unzip curl wget nginx certbot python3-certbot-nginx
5. Install Docker
Run:
sudo apt install -y docker.io
Enable and start Docker:
sudo systemctl enable docker
sudo systemctl start docker
Check Docker:
docker --version
6. Install Docker Compose
First try:
sudo apt install -y docker-compose
Check:
docker-compose --version
If docker-compose is still not found, install manually:
sudo curl -L "https://github.com/docker/compose/releases/download/v2.27.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Check again:
docker-compose --version
7. Important Note About Judge0 Package
Do not use this package for our setup:
judge0-v1.13.0-https.zip
Because it starts its own Docker Nginx container and tries to use port 80.
We are using system Nginx and Certbot SSL, so use normal package:
judge0-v1.13.0.zip
8. Stop Wrong HTTPS Package If Already Running
If HTTPS package was already started, stop it:
cd /judge0-v1.13.0/judge0-v1.13.0-https
docker-compose down
Check running containers:
docker ps
9. Download Normal Judge0 Package
Create folder:
cd /
mkdir -p /judge0-normal
cd /judge0-normal
Download Judge0:
wget https://github.com/judge0/judge0/releases/download/v1.13.0/judge0-v1.13.0.zip
Unzip:
unzip judge0-v1.13.0.zip
Go to Judge0 folder:
cd judge0-v1.13.0
10. Configure Judge0 Passwords
Open config file:
nano judge0.conf
Find these values:
REDIS_PASSWORD=
POSTGRES_PASSWORD=
Set strong passwords:
REDIS_PASSWORD=YourStrongRedisPassword123
POSTGRES_PASSWORD=YourStrongPostgresPassword123
Save file.
In nano:
CTRL + O -> Enter
CTRL + X -> Exit
11. Start Judge0
Start database and Redis first:
docker-compose up -d db redis
Wait 10 seconds:
sleep 10s
Start all Judge0 services:
docker-compose up -d
Check containers:
docker-compose ps
Expected services:
db
redis
server
workers
12. Test Judge0 Locally
Run:
curl http://localhost:2358/about
Also test:
curl http://localhost:2358/languages
If you get JSON response, Judge0 is running correctly.
13. Configure Nginx Reverse Proxy
Create Nginx config:
sudo nano /etc/nginx/sites-available/judge.tr**klms.org
Paste this:
server {
listen 80;
server_name judge.tr**klms.org;
client_max_body_size 100M;
location / {
proxy_pass http://127.0.0.1:2358;
proxy_http_version 1.1;
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 300;
proxy_connect_timeout 300;
proxy_send_timeout 300;
}
}
Save and exit.
Enable site:
sudo ln -s /etc/nginx/sites-available/judge.tr**klms.org /etc/nginx/sites-enabled/
Remove default site:
sudo rm -f /etc/nginx/sites-enabled/default
Test Nginx:
sudo nginx -t
Restart Nginx:
sudo systemctl restart nginx
Now check:
http://judge.tr**klms.org/docs
14. Install SSL Certificate
Run Certbot:
sudo certbot --nginx -d judge.tr**lms.org
When it asks for redirect, select redirect HTTP to HTTPS.
After SSL installation, open:
https://judge.tr**klms.org/docs
15. Final URLs
Judge0 API base URL:
https://judge.tr**klms.org
Judge0 API documentation:
https://judge.tr**klms.org/docs
Languages API:
https://judge.tr**klms.org/languages
About API:
https://judge.tr**klms.org/about
16. Useful Commands
Go to Judge0 folder:
cd /judge0-normal/judge0-v1.13.0
Check running containers:
docker-compose ps
View logs:
docker-compose logs -f
View server logs only:
docker-compose logs -f server
Restart Judge0:
docker-compose restart
Stop Judge0:
docker-compose down
Start Judge0 again:
docker-compose up -d db redis
sleep 10s
docker-compose up -d
Restart Nginx:
sudo systemctl restart nginx
Check Nginx config:
sudo nginx -t
Check SSL renewal:
sudo certbot renew --dry-run
17. Issue Faced and Solution
Issue
While using:
judge0-v1.13.0-https.zip
Docker showed this error:
failed to bind host port 0.0.0.0:80/tcp: address already in use
Reason
The HTTPS package starts its own Docker Nginx container on port 80.
But our EC2 server already had system Nginx running on port 80.
So two Nginx services were trying to use the same port.
Solution
We stopped the HTTPS package and used the normal Judge0 package:
judge0-v1.13.0.zip
Then we used system Nginx as reverse proxy with Certbot SSL.
18. Final Deployment Flow Summary
AWS EC2 Ubuntu Server
↓
Docker + Docker Compose installed
↓
Judge0 normal package installed
↓
Judge0 runs internally on port 2358
↓
Nginx reverse proxy handles domain
↓
Certbot adds SSL
↓
Final URL: https://judge.tr**klms.org/docs
Final setup:
Public URL:
https://judge.tr**klms.org
Internal Judge0:
http://127.0.0.1:2358
0 comments:
Post a Comment