NEWUse coupon code SMX20 to get 20% OFF your first billing cycle on any game server or VPS!Explore Store

VPS HOSTING

How to Host a Private Git Server Using Gitea on a VPS

Self-host Git with Gitea on a VPS using Docker Compose and PostgreSQL: HTTPS with Nginx, SSH clone access, first-run settings, disabling public sign-up, Gitea Actions runners, backups and upgrades.

Gitea is a lightweight, open-source Git service written in Go: repositories, pull requests, issues, wikis, packages and a GitHub Actions–compatible CI system, all in a single binary. Hosting it on your own VPS gives you private repositories without per-user fees, your code on a server you control, and fast clones from India. This guide sets up a production-ready instance.

What You Need

  • A VPS with Docker and Docker Compose (see our Docker guide).
  • A domain or subdomain, for example git.example.com, pointing to the server.
  • Nginx and Certbot for HTTPS (see our Let's Encrypt guide).

Step 1: Docker Compose

# /srv/gitea/docker-compose.yml
services:
  gitea:
    image: gitea/gitea:1        # pin to a specific version in production
    environment:
      - USER_UID=1000
      - USER_GID=1000
      - GITEA__database__DB_TYPE=postgres
      - GITEA__database__HOST=db:5432
      - GITEA__database__NAME=gitea
      - GITEA__database__USER=gitea
      - GITEA__database__PASSWD=${DB_PASSWORD}
    volumes:
      - ./data:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "127.0.0.1:3000:3000"
      - "2222:22"
    depends_on: [db]
    restart: unless-stopped

  db:
    image: postgres:16
    environment:
      - POSTGRES_USER=gitea
      - POSTGRES_PASSWORD=${DB_PASSWORD}
      - POSTGRES_DB=gitea
    volumes:
      - ./postgres:/var/lib/postgresql/data
    restart: unless-stopped
cd /srv/gitea
echo "DB_PASSWORD=$(openssl rand -hex 24)" > .env
chmod 600 .env
docker compose up -d

The web port is bound to localhost so only Nginx can reach it. Port 2222 is published for Git over SSH; allow it in the firewall with sudo ufw allow 2222/tcp. Docker-published ports bypass UFW, so publishing the web port on localhost matters.

Step 2: Nginx and HTTPS

server {
    listen 80;
    server_name git.example.com;
    client_max_body_size 512m;    # large pushes and release uploads

    location / {
        proxy_pass http://127.0.0.1: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;
    }
}
sudo nginx -t && sudo systemctl reload nginx
sudo certbot --nginx -d git.example.com

Step 3: First-Run Configuration

Open https://git.example.com. In the installer:

  • Server domain: git.example.com
  • Gitea base URL: https://git.example.com/
  • SSH server port: 2222 (the port users connect to, so clone URLs are correct)
  • Disable self-registration unless you want anyone to create accounts.
  • Create the administrator account.

Settings are stored in data/gitea/conf/app.ini. You can also set any option through GITEA__section__KEY environment variables in the Compose file.

Step 4: Lock It Down

  • Keep registration disabled and create accounts as admin, or require email confirmation and admin approval.
  • Set new repositories to private by default ([repository] DEFAULT_PRIVATE = private).
  • Require two-factor authentication for administrators.
  • Restrict REQUIRE_SIGNIN_VIEW = true under [service] if nothing should be visible without logging in.
  • Keep the server's SSH (port 22) for administration with keys only; Gitea's SSH on 2222 is only for Git.

Step 5: Clone and Push

Users add their public SSH keys under Settings → SSH/GPG Keys, then:

git clone ssh://git@git.example.com:2222/team/project.git
# or over HTTPS with a personal access token
git clone https://git.example.com/team/project.git

To migrate existing repositories, use "New Migration", which imports from GitHub, GitLab and others, including issues and pull requests where supported.

Step 6: CI with Gitea Actions

Gitea Actions uses workflow files compatible with GitHub Actions syntax in .gitea/workflows/. Jobs run on a separate runner, act_runner:

  1. Enable Actions in the site administration if it is not already enabled for your version.
  2. Create a runner registration token in the admin panel.
  3. Run act_runner (as a container or binary) on the same or, better, a separate server, and register it with the token.

CI jobs can use much more CPU and memory than Gitea itself, and they run code from your repositories, so a separate runner server keeps builds from slowing Git operations and limits the impact of a malicious build script.

Step 7: Backups

Gitea's dump command creates an archive of repositories, configuration and a database dump:

docker compose exec -u git gitea gitea dump -c /data/gitea/conf/app.ini --file /data/gitea-dump.zip
mv data/gitea-dump.zip /var/backups/gitea-$(date +%F).zip

Run it nightly from cron (see our cron guide), copy archives off the server, keep several days, and test restoring to a staging server. Alternatively, stop the stack briefly and archive the data and postgres directories together with a PostgreSQL dump.

Features Worth Enabling

  • Branch protection: require pull requests and passing checks before merging to the main branch.
  • Package registry: Gitea can host container images and packages for npm, PyPI, Maven, Composer and others, so private packages live next to their code.
  • Mirrors: push mirrors keep an off-site copy on another Git host; pull mirrors track upstream open-source projects.
  • Webhooks: notify chat tools or trigger deployments on push.
  • Organisations and teams: grant repository access by team rather than per user.

Step 8: Upgrades

Read the release notes, back up, change the image tag, then:

docker compose pull && docker compose up -d
docker compose logs -f gitea

Gitea migrates its database automatically on start. Upgrade one major version at a time if the release notes ask you to.

ServoMix Plans for This Workload

Gitea itself is light: a small team's repositories run comfortably on the 2 vCore / 8 GB tier. Add vCores and RAM if the same server runs Gitea Actions jobs, which use far more resources than Git hosting.

AMD EPYC 7C13 VPS

Dedicated KVM vCores on AMD EPYC 7C13 (up to 3.70 GHz) with DDR4 ECC memory, NVMe SSD and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vPro XS (AMD EPYC)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹420/moWebsites, small APIs, bots, staging and VPN serversOrder
SMX vPro S (AMD EPYC)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹560/moWooCommerce, Node.js/Python backends, Docker Compose stacks, CI runnersOrder
SMX vPro M (AMD EPYC)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹840/moProduction databases, high-traffic sites, multi-container appsOrder
SMX vPro L (AMD EPYC)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹1,120/moLarge production workloads, SaaS platforms, analytics, in-memory cachesOrder

Intel Xeon Platinum 8269CY VPS

KVM VPS on Intel Xeon Platinum 8269CY (up to 3.80 GHz Turbo) with DDR4 ECC memory, NVMe SSD, full root access and an unmetered 1 Gbps port.

PlanvCoresRAMStorageNetworkPriceGood forBuy
SMX vCore XS (Intel Xeon)28 GB DDR4 ECC40 GB NVMe SSD1 Gbps, unmetered₹270/moBusiness websites, small apps, scheduled jobs and botsOrder
SMX vCore S (Intel Xeon)416 GB DDR4 ECC80 GB NVMe SSD1 Gbps, unmetered₹1,169/monthBusiness software, mid-size databases, several sites on one serverCheck stock
SMX vCore M (Intel Xeon)832 GB DDR4 ECC150 GB NVMe SSD1 Gbps, unmetered₹2,249/monthERP/CRM stacks, heavier databases, multiple production appsCheck stock
SMX vCore L (Intel Xeon)1664 GB DDR4 ECC250 GB NVMe SSD1 Gbps, unmetered₹4,248/monthHigh-memory workloads and consolidated production serversCheck stock

Prices are monthly in INR as listed on the ServoMix store (verified 2026-11-14). Stock and final pricing are shown on the product page at checkout.

Frequently Asked Questions

What is Gitea?
An open-source, lightweight self-hosted Git service with repositories, pull requests, issues, wikis, package registries and GitHub Actions–compatible CI.
How much RAM does Gitea need?
Gitea itself is light and runs well on a small server for a team. CI runners and large repositories need more; size for the Actions jobs if they run on the same server.
Why use port 2222 for Git over SSH?
The server's own SSH daemon already uses port 22. Publishing Gitea's SSH on 2222 keeps them separate; set the SSH port in Gitea so clone URLs include it.
Can Gitea run GitHub Actions workflows?
Gitea Actions uses a largely compatible syntax and runs jobs on act_runner. Many marketplace actions work, but check those that depend on GitHub-specific features.
How do I stop strangers from signing up?
Disable self-registration in the installer or in app.ini, and create accounts as an administrator.
How do I back up Gitea?
Run gitea dump nightly, copy the archive off-site and test restores. It includes repositories, configuration and the database.
Can I migrate repositories from GitHub?
Yes. Gitea's migration tool imports repositories and, where supported, issues, labels, milestones and pull requests.
Should CI runners run on the Gitea server?
For small teams it can, but a separate runner server avoids builds slowing Git operations and isolates untrusted build code.
Is SQLite enough instead of PostgreSQL?
SQLite works for small single-user or very small team instances. PostgreSQL is more robust for teams and concurrent use.
Which ServoMix plan suits Gitea?
The 2 vCore / 8 GB AMD EPYC or Intel VPS runs Gitea for a team; add a second VPS or choose 4 vCores / 16 GB if Actions jobs run on the same server.

Frequently Asked Questions

What is Gitea?

An open-source, lightweight self-hosted Git service with repositories, pull requests, issues, wikis, package registries and GitHub Actions–compatible CI.

How much RAM does Gitea need?

Gitea itself is light and runs well on a small server for a team. CI runners and large repositories need more; size for the Actions jobs if they run on the same server.

Why use port 2222 for Git over SSH?

The server's own SSH daemon already uses port 22. Publishing Gitea's SSH on 2222 keeps them separate; set the SSH port in Gitea so clone URLs include it.

Can Gitea run GitHub Actions workflows?

Gitea Actions uses a largely compatible syntax and runs jobs on act_runner . Many marketplace actions work, but check those that depend on GitHub-specific features.

How do I stop strangers from signing up?

Disable self-registration in the installer or in app.ini , and create accounts as an administrator.

How do I back up Gitea?

Run gitea dump nightly, copy the archive off-site and test restores. It includes repositories, configuration and the database.

Can I migrate repositories from GitHub?

Yes. Gitea's migration tool imports repositories and, where supported, issues, labels, milestones and pull requests.

Should CI runners run on the Gitea server?

For small teams it can, but a separate runner server avoids builds slowing Git operations and isolates untrusted build code.

Is SQLite enough instead of PostgreSQL?

SQLite works for small single-user or very small team instances. PostgreSQL is more robust for teams and concurrent use.

Which ServoMix plan suits Gitea?

The 2 vCore / 8 GB AMD EPYC or Intel VPS runs Gitea for a team; add a second VPS or choose 4 vCores / 16 GB if Actions jobs run on the same server.

Was this article helpful?

Your feedback helps us continuously improve ServoMix guides.

Share this article

Know someone who may find this guide useful?

Host a Private Git Server with Gitea on a VPS | ServoMix