๐ Deploying Gitea on AWS EC2 with Docker, Nginx & SSL (Step-by-Step Guide)
In this guide, weโll walk through setting up your own self-hosted Git service using Gitea on an AWS EC2 instance. Weโll cover everythingโฆ
๐ Deploying Gitea on AWS EC2 with Docker, Nginx & SSL (Step-by-Step Guide)
In this guide, weโll walk through setting up your own self-hosted Git service using Gitea on an AWS EC2 instance. Weโll cover everything from server setup to Docker installation, reverse proxy configuration with Nginx, SSL setup, and final Gitea configuration.
โ๏ธ 1. Launch EC2 & Configure Security Group
Start by launching an Ubuntu EC2 instance (20.04 or 22.04 recommended).
๐ Security Group Rules
Allow the following inbound ports:
PortPurpose22SSH access80HTTP (Nginx)443HTTPS (SSL)3000(optional) direct Gitea access222Gitea SSH (for Git operations)
๐ ๏ธ 2. Install Dependencies
SSH into your EC2 instance:
ssh ubuntu@YOUR_EC2_IP
Update system
sudo apt update && sudo apt upgrade -y
๐ณ Install Docker
sudo apt install -y docker.io
sudo systemctl enable docker
sudo systemctl start docker
Add user to docker group
sudo usermod -aG docker ubuntu
newgrp docker
๐ฆ Install Docker Compose
sudo apt install -y docker-compose
๐ Install Nginx
sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
๐ Install Certbot (SSL)
sudo apt install -y certbot python3-certbot-nginx
๐ 3. Setup Gitea with Docker
Create project directory:
mkdir gitea && cd gitea
cd gitea
nano docker-compose.yml
Create docker-compose.yml:
version: "3"
services:
server:
image: docker.gitea.com/gitea:1
container_name: gitea
restart: always
environment:
- USER_UID=1000
- USER_GID=1000
volumes:
- ./gitea:/data
ports:
- "3000:3000"
- "222:22"
Start Gitea
cd gitea
docker-compose up -d
Verify:
docker ps -a
๐ 4. Configure Nginx (Reverse Proxy)
Create config:
sudo nano /etc/nginx/sites-available/gitea
Paste:
server {
listen 80;
server_name gitea.yourdomain.com;
location / {
proxy_pass http://localhost:3000;
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;
}
}
Enable config:
sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl restart nginx
๐ 5. Enable HTTPS (SSL)
Run:
sudo certbot --nginx
Follow prompts and select your domain.
After success, your site will be available at:
https://gitea.yourdomain.com
โ๏ธ 6. Gitea Initial Setup (Web UI)
Open your browser:
https://gitea.yourdomain.com
Fill the form like this:
๐๏ธ Database
- Type: SQLite3
- Path:
/data/gitea/gitea.db
โ๏ธ General Settings
Change SSH port to 222 and leave Rest of setting default
๐ค Admin Account
Create your admin user:
- Username
- Password
๐ 7. SSH Configuration (Important)
Since Docker maps:
222 โ 22
๐ You must use port 222 for Git operations.
Example clone:
git clone ssh://git@gitea.yourdomain.com:222/username/repo.git
๐ Final Result
You now have:
- โ Self-hosted Git server (Gitea)
- โ Running on Docker
- โ Nginx reverse proxy
- โ HTTPS enabled (SSL)
- โ SSH Git access on port 222
๐ง Key Takeaways
- Always use reverse proxy (Nginx) in production
- Use HTTPS (SSL) for security
- Configure correct Base URL in Gitea
- Use custom SSH port (222) when using Docker
๐ฏ Whatโs Next?
You can now:
- Create repositories
- Add team members
- Setup CI/CD (Gitea Actions)
- Configure backups
- Integrate with your projects
๐ฌ Conclusion
With minimal resources, youโve built a powerful, self-hosted Git platform. Gitea is lightweight, fast, and perfect for teams or personal projects.
๋ฉํ๋ฐ์ดํฐ
- post_id
- b0f44baa943d
- slug
- deploying-gitea-on-aws-ec2-with-docker-nginx-ssl-step-by-step-guide-b0f44baa943d
- url
- https://medium.com/@i211232/deploying-gitea-on-aws-ec2-with-docker-nginx-ssl-step-by-step-guide-b0f44baa943d
- canonical_url
- https://medium.com/@i211232/deploying-gitea-on-aws-ec2-with-docker-nginx-ssl-step-by-step-guide-b0f44baa943d
- author_url
- https://medium.com/@i211232
- status
- ok
- fetched_at
- 2026-06-20 20:29:01