Self-host guide

How to Self-Host Gitea on a VPS

Run Gitea 28 on Ubuntu 24.04 with Gitea's Docker Compose file and Caddy for HTTPS, set the SSH clone port, then back up with gitea dump and update.

Gitea is a self-hosted Git service with repositories, issues, pull requests, wikis, package registries and Gitea Actions for CI. This guide installs it by hand on Ubuntu 24.04 with the Docker Compose file from Gitea's docs, using SQLite, and puts Caddy in front for HTTPS.

Prefer one click? Deploy Gitea from the VeloxaHost marketplace and skip the manual steps; this guide is for when you want to run every command yourself.

What you need

  • A VeloxaHost server with the Ubuntu 24.04 LTS image. You get root, over SSH or in the browser terminal on the server's page.
  • A domain or subdomain, such as git.example.com.
  • A dedicated IPv4 address for HTTPS. Caddy gets its certificate over ports 80 and 443, which the shared IPv4 address does not offer; it only gives you a block of forwarded ports. A dedicated IPv4 is a paid add-on (the console shows the current price): choose it as "Network access" on the create page, or take one from the IP addresses page and attach it. If none is free in the region, the request is refused.

Gitea's docs give no hardware minimum for a small instance; it is a single Go binary, and SQLite needs no database server. A Veloxa 1 (1 vCPU, 2 GB RAM, 50 GB disk) at $8 a month, billed at $0.02 an hour and capped at the monthly price, fits a small team. Repositories, packages and CI jobs are what grow, so size the disk for them.

Install Gitea

  1. Bring up the dedicated address. The server must answer on it: add it to the interface (check the name with ip addr), add it to the network configuration too so it survives a reboot, and point an A record for git.example.com at it. IPv6 is not available in US East yet, so skip the AAAA record.

    ip addr add 198.51.100.5/32 dev eth0
    
  2. Install Docker Engine and the Compose plugin from Docker's apt repository, as in Docker's Ubuntu guide. sudo also works as root.

    # Add Docker's official GPG key:
    sudo apt update
    sudo apt install ca-certificates curl
    sudo install -m 0755 -d /etc/apt/keyrings
    sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
    sudo chmod a+r /etc/apt/keyrings/docker.asc
    
    # Add the repository to Apt sources:
    sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
    Types: deb
    URIs: https://download.docker.com/linux/ubuntu
    Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
    Components: stable
    Architectures: $(dpkg --print-architecture)
    Signed-By: /etc/apt/keyrings/docker.asc
    EOF
    
    sudo apt update
    sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
    sudo docker run hello-world
    
  3. Create the project directory and the data folder. Gitea's docs say the data volume must be owned by the UID and GID set in the file, 1000 by default; the chown is ours.

    mkdir -p /opt/gitea/gitea && cd /opt/gitea
    chown 1000:1000 gitea
    
  4. Create docker-compose.yml. This is the docs' basic SQLite example, pinned to 28.2.0, the current release when this was checked. One change: the web port is published on 127.0.0.1 only, so the outside reaches Gitea through Caddy.

    networks:
      gitea:
        external: false
    
    services:
      server:
        image: docker.gitea.com/gitea:28.2.0
        container_name: gitea
        environment:
          - USER_UID=1000
          - USER_GID=1000
        restart: always
        networks:
          - gitea
        volumes:
          - ./gitea:/data
          - /etc/timezone:/etc/timezone:ro
          - /etc/localtime:/etc/localtime:ro
        ports:
          - "127.0.0.1:3000:3000"
          - "222:22"
    

    Port 222 on the server reaches the SSH server inside the container, so Git over SSH does not clash with your own SSH on port 22.

  5. Start it and check the logs.

    docker compose up -d
    docker compose ps
    docker compose logs
    
  6. Install Caddy from its apt repository, as in Caddy's install docs.

    sudo apt install --yes debian-keyring debian-archive-keyring apt-transport-https curl
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
    curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
    sudo chmod o+r /usr/share/keyrings/caddy-stable-archive-keyring.gpg
    sudo chmod o+r /etc/apt/sources.list.d/caddy-stable.list
    sudo apt update
    sudo apt install caddy
    
  7. Replace /etc/caddy/Caddyfile with the block from Gitea's reverse proxy page, then reload Caddy. It gets and renews the certificate on its own.

    git.example.com {
        reverse_proxy localhost:3000
    }
    
    sudo systemctl reload caddy
    

First login

Open https://git.example.com. The first visit shows the installer:

  • Database type: SQLite3. The file goes under /data in the container, which is /opt/gitea/gitea on the server.
  • Server domain: git.example.com. Gitea Base URL: https://git.example.com/. This is ROOT_URL, which Gitea needs behind a proxy.
  • SSH server port: the public port people will clone over. With a dedicated IPv4 that is 222. Without one, forward a port of your block to 222 on the server's page and enter that public port. This only changes the clone URLs Gitea shows.
  • Administrator account settings: create your admin user here.

Gitea saves the result to /data/gitea/conf/app.ini. In current releases DISABLE_REGISTRATION defaults to true, so only the admin can create accounts. Check the setting under Site Administration before you invite anyone.

Secure it

Firewall. VeloxaHost firewalls are network-level and stateful. Until you attach one, all traffic is allowed (except outbound TCP 25). Go to Firewalls, New Firewall, Add Rule: allow TCP 80 and 443 from 0.0.0.0/0, TCP 222 from the addresses that push over SSH, and TCP 22 only from YOUR.IP/32. Attach it on the server's page. Ports published by Docker bypass ufw, so rely on the VeloxaHost firewall.

Private instance. To hide everything from visitors who are not logged in, add an environment line; every app.ini key can be set as GITEA__section__KEY:

      - GITEA__service__REQUIRE_SIGNIN_VIEW=true

Run docker compose up -d after any change to the file.

Accounts. Turn on two-factor authentication for the admin account in its settings, and give people their own accounts rather than sharing one.

Email. Outbound port 25 is blocked by default, so use your provider's port 465. The Docker docs show the mailer settings, with values coming from your environment:

      - GITEA__mailer__ENABLED=true
      - GITEA__mailer__FROM=${GITEA__mailer__FROM:?GITEA__mailer__FROM not set}
      - GITEA__mailer__PROTOCOL=smtps
      - GITEA__mailer__SMTP_ADDR=${GITEA__mailer__SMTP_ADDR:?GITEA__mailer__SMTP_ADDR not set}
      - GITEA__mailer__SMTP_PORT=${GITEA__mailer__SMTP_PORT:?GITEA__mailer__SMTP_PORT not set}
      - GITEA__mailer__USER=${GITEA__mailer__USER:-apikey}
      - GITEA__mailer__PASSWD="""${GITEA__mailer__PASSWD:?GITEA__mailer__PASSWD not set}"""

Back it up

Everything lives in /opt/gitea/gitea: repositories, the SQLite database, attachments and app.ini, which holds the SECRET_KEY. Gitea's docs warn not to lose or change that key, or encrypted data can no longer be decrypted.

gitea dump packs it all into one zip. Run it as the git user, in a directory that user can write; here /data, so the zip lands in /opt/gitea/gitea on the server.

docker exec -u git -it -w /data $(docker ps -qf 'name=^gitea$') bash -c '/usr/local/bin/gitea dump -c /data/gitea/conf/app.ini'

The docs also say Gitea must be shut down for a fully consistent backup. For that, stop it and archive the folder (our commands):

cd /opt/gitea
docker compose stop
tar czf /root/gitea-$(date +%F).tar.gz gitea
docker compose start

To restore a dump in Docker, the docs move data into /data/gitea and repos into /data/git/repositories, fix ownership with chown -R git:git /data, then regenerate the Git hooks (see Troubleshooting).

On VeloxaHost, snapshots are instant and free (5 on Starter, 30 on Pay as you go): server page, Snapshots, name, Create. Restoring overwrites the current state. Automatic snapshots run every hour, 6 hours, 12 hours, daily or weekly, kept for 1, 3, 7, 14 or 30 days. The Backups page creates, downloads and restores server backups (as a new server), on a schedule of every 6 hours, 12 hours, daily or weekly, keeping 1 to 10. Download one now and then for an off-site copy.

Update it

Read the changelog for breaking changes first. Gitea migrates its database on start and an upgraded database cannot run an older Gitea, so take a snapshot. Then change the tag in docker-compose.yml and run the docs' steps:

cd /opt/gitea
docker compose pull
docker compose up -d

Releases that share the first two numbers (28.2.x) are compatible with each other. The docs list latest as a stable tag too, but a pinned tag means updates happen when you choose.

Troubleshooting

The container keeps restarting with permission errors. The data folder is not owned by UID 1000. Run chown -R 1000:1000 /opt/gitea/gitea and start again.

Compose fails to mount /etc/timezone. The file is missing on the server. Check with ls -l /etc/timezone; if it is absent, remove that line from the volumes.

Clone URLs show the wrong port or localhost. Set SSH_PORT and ROOT_URL in the [server] section of app.ini, then restart the container.

Pushes fail after a restore or a move. Regenerate the Git hooks with docker exec -u git -it gitea /usr/local/bin/gitea -c /data/gitea/conf/app.ini admin regenerate hooks.

FAQ

What license is Gitea under?

Gitea is released under the MIT license. The project also sells Gitea Enterprise; the image used here is the free one, with the Git hosting features described in this guide.

How do people clone over SSH on the shared IPv4 address?

Forward a port of your block to 222 on the server's page, and enter that public port as the SSH server port in the installer, or as SSH_PORT in app.ini. Clone URLs then include it. With a dedicated IPv4, port 222 works directly.

Should I use SQLite or PostgreSQL?

SQLite needs no extra server and suits a small team. Gitea's docs suggest choosing the final database type at the first install, because converting later with gitea dump is not well tested. For a larger team, start with the docs' PostgreSQL Compose example instead.

Which image tag should I use?

Pin a release such as docker.gitea.com/gitea:28.2.0 and move it forward yourself. The docs warn that the rootful and rootless images are not compatible, so do not switch between them by changing the image name.

Which VeloxaHost size fits Gitea?

A Veloxa 1 (1 vCPU, 2 GB RAM, 50 GB disk) at $8 a month, billed at $0.02 an hour and capped at the monthly price, fits a small team. If you run Gitea Actions jobs on the same server, a Veloxa 2 (2 vCPU, 4 GB RAM, 80 GB disk) at $15 a month, billed at $0.03 an hour and capped at the monthly price, leaves room for builds.

Commands and settings checked on 2026-10-19 against the official documentation: docs.gitea.com, dl.gitea.com, github.com, docs.docker.com, caddyserver.com. Software changes; if a step no longer matches, the vendor's docs win.

Ready to deploy?

Start a free trial, or compare plans to match your team's scale.