Self-Hosted Git Server with Gitea: Complete Setup Guide 2026
If you’re managing code, infrastructure, or even personal projects, keeping everything on GitHub or GitLab eventually raises questions about access control, privacy, and vendor lock-in. A self-hosted Git server with Gitea gives you full control over repositories, users, and permissions on your own hardware.
Why Gitea Instead of GitHub
Gitea is a lightweight, open-source Git service written in Go. It uses minimal resources compared to GitLab, yet still provides pull requests, issues, wikis, and CI/CD hooks. You can run it on a Raspberry Pi, a small VM, or a container in your homelab.
Prerequisites
- A Linux server or VM (Debian/Ubuntu recommended)
- Docker or a standalone binary
- A domain name pointing to your server
- A reverse proxy like Nginx Proxy Manager
- SSL certificate via Let’s Encrypt
Install with Docker Compose
The fastest path is Docker Compose. Create a project directory and add:
version: "3.9"
services:
gitea:
image: gitea/gitea:latest
restart: unless-stopped
environment:
- USER_UID=1000
- USER_GID=1000
volumes:
- ./gitea:/data
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "3000:3000"
- "2222:22"
networks:
- proxy
networks:
proxy:
external: true
Run docker compose up -d and access Gitea at http://localhost:3000.
Initial Setup
Open the web UI and complete the installation wizard:
- Database: SQLite for small setups, PostgreSQL for production
- Domain: git.yourdomain.com
- SSH port: 2222 (mapped from container port 22)
- Admin account: create your first user with admin rights
Configure Nginx Proxy Manager
Add a proxy host:
- Domain: git.yourdomain.com
- Forward to: your-server-ip:3000
- SSL: Let’s Encrypt, force HTTPS, HTTP/2
This gives you HTTPS without touching Gitea’s internal config.
Essential Hardening
- Enable two-factor authentication for all users
- Disable public registration if this is for a team
- Restrict SSH to key-based auth only
- Schedule regular backups of
/data - Limit Gitea to the internal Docker network if possible
Why This Works Better
Most teams default to public SaaS because it’s easy. A self-hosted Git server with Gitea removes that dependency. You keep full control over repositories, you can integrate directly with internal CI/CD, and you avoid rate limits and privacy concerns.
Final Thoughts
Gitea is one of the best balance points in the self-hosted Git space: lightweight enough for a Pi, powerful enough for a team. Start with SQLite, add PostgreSQL when you outgrow it, and expand with webhooks, Actions runners, and registry mirrors. Your homelab will thank you.