Gitea is a lightweight, self-hosted Git service, similar to GitHub or GitLab. You get private repositories, pull requests, issues, a wiki, and built-in CI/CD (Gitea Actions), with your code stored on your own VPS. It's fast and runs happily on a small server.
This guide runs Gitea in Docker, with Caddy in front of it to provide a free HTTPS certificate automatically. It works on every operating system we offer: Ubuntu 22.04, 24.04 and 26.04, Debian 12 and 13, AlmaLinux 8, 9 and 10, and Rocky Linux 9 and 10.
Before you start
- Docker must be installed. If it isn't, follow our guide: Install Docker Engine and Docker Compose on your VPS.
- A VPS with at least 1 GB of RAM, and enough disk for your repositories.
- A domain or subdomain with an A record pointing to your VPS IP address, for example
git.example.co.nz. - Nothing else using ports 80 or 443 on the server. If you already use Nginx Proxy Manager, see the note near the end.
- SSH access as root or as a user with sudo rights. If you're logged in as root, you can leave
sudooff the commands.
Step 1: Open the firewall
Gitea needs ports 80 and 443 for the website, and port 2222 for Git over SSH. Your server's own SSH stays on port 22.
Ubuntu/Debian with UFW enabled:
sudo ufw allow 80/tcp
sudo ufw allow 443
sudo ufw allow 2222/tcp
AlmaLinux/Rocky with firewalld:
sudo firewall-cmd --permanent --add-service=http --add-service=https --add-port=443/udp --add-port=2222/tcp
sudo firewall-cmd --reload
Step 2: Create the configuration files
sudo mkdir -p /opt/gitea
cd /opt/gitea
sudo nano .env
Paste in the following, replacing the domain with your own:
DOMAIN=git.example.co.nz
Press Ctrl+O and Enter to save, then Ctrl+X to exit. Next, create the Docker Compose file:
sudo nano compose.yaml
Paste in the following. You don't need to change anything in this file.
services:
gitea:
image: docker.gitea.com/gitea:1
container_name: gitea
restart: unless-stopped
environment:
- USER_UID=1000
- USER_GID=1000
- GITEA__server__DOMAIN=${DOMAIN}
- GITEA__server__ROOT_URL=https://${DOMAIN}/
- GITEA__server__SSH_DOMAIN=${DOMAIN}
- GITEA__server__SSH_PORT=2222
volumes:
- ./gitea:/data
- /etc/localtime:/etc/localtime:ro
ports:
- "2222:22"
caddy:
image: caddy:2
container_name: caddy
restart: unless-stopped
environment:
- DOMAIN=${DOMAIN}
ports:
- "80:80"
- "443:443"
- "443:443/udp"
volumes:
- ./Caddyfile:/etc/caddy/Caddyfile:ro
- caddy_data:/data
- caddy_config:/config
volumes:
caddy_data:
caddy_config:
Save and exit. Finally, create the Caddy configuration:
sudo nano Caddyfile
Paste in the following exactly as shown:
{$DOMAIN} {
reverse_proxy gitea:3000
}
Save and exit.
Step 3: Start Gitea
sudo docker compose up -d
Caddy gets an SSL certificate for your domain automatically. This usually takes under a minute.
Step 4: Run the setup wizard
Open https://git.example.co.nz in your browser. You'll see the Initial Configuration page.
- Database Type: choose SQLite3. It's the simplest option and works well for individuals and small teams.
- Check that Server Domain, SSH Server Port (2222) and Gitea Base URL (
https://git.example.co.nz/) are filled in correctly. - Expand Server and Third-Party Service Settings and tick Disable Self-Registration, so strangers can't create accounts on your server.
- Expand Administrator Account Settings and create your admin account with a strong password.
- Click Install Gitea.
Step 5: Add your SSH key and create a repository
- In Gitea, go to your avatar → Settings → SSH / GPG Keys and add the public key from your computer (for example, the contents of
~/.ssh/id_ed25519.pub). - Click + → New Repository, give it a name and create it.
- Clone it on your computer over SSH:
git clone ssh://git@git.example.co.nz:2222/YOUR_USERNAME/YOUR_REPO.git
Or over HTTPS: git clone https://git.example.co.nz/YOUR_USERNAME/YOUR_REPO.git
To bring existing projects across, use + → New Migration. Gitea can import repositories, issues and more from GitHub, GitLab, Bitbucket and others.
Back up your data
All your repositories, settings and the database are stored in /opt/gitea/gitea. Back it up regularly, and keep copies off the server:
cd /opt/gitea
sudo docker compose stop gitea
sudo tar czf /root/gitea-backup-$(date +%F).tar.gz gitea
sudo docker compose start gitea
Keeping it up to date
Check the Gitea release notes for anything to watch out for, take a backup, then run:
cd /opt/gitea
sudo docker compose pull
sudo docker compose up -d
Already using Nginx Proxy Manager?
Leave out the caddy service and the Caddyfile, add Gitea to your proxy network, and create a proxy host pointing to gitea on port 3000 with an SSL certificate. Keep the 2222:22 port mapping for Git over SSH.
Troubleshooting
- The site won't load over HTTPS: check the Caddy logs with
sudo docker logs caddy. The usual cause is DNS that doesn't point to this VPS yet, or ports 80 and 443 being blocked. - Git over SSH asks for a password or is refused: make sure you're using port 2222 in the clone URL, that port 2222 is open, and that your public key is added in Gitea.
- Clone URLs show the wrong address: check
DOMAINin/opt/gitea/.env. You can also correctROOT_URLin/opt/gitea/gitea/gitea/conf/app.ini, then runsudo docker compose restart gitea. - Gitea won't start: check the logs with
sudo docker logs gitea.
Need help?
Our Cloud VPS plans are self-managed, so you're responsible for installing, securing and maintaining the software on your server. If something on our side isn't working, such as the network, or your VPS won't boot, open a support ticket. New to your VPS? Start with our Cloud VPS Getting Started Guide.







