# Self-host Gitea

> Self-hosted Git service that also provides code review, issue tracking, a wiki, a package registry and CI/CD. Run your own Gitea on an always-on EnvHaven workspace by asking its coding agent: one request installs it, puts it on an HTTPS address and locks it down. What the agent takes care of, and the manual route.

_Updated November 23, 2026_

Running your own Gitea usually means a list of server chores: a machine that stays on, Docker or a runtime, a reverse proxy with certificates, a domain, and the settings that make Gitea behave behind all of it. On an EnvHaven workspace you skip the list. You ask the coding agent, and it does the work while you watch.

## Just ask your agent

Open a Hobby workspace, tap **Launch** to start any coding agent (Claude Code, Codex, OpenCode or another), and ask it:

```text
Set up Gitea on this workspace and give me the link. Follow https://envhaven.com/self-host/gitea.md
```

Then open the link it sends and create your Gitea account straight away, before anyone else finds the address. That is the whole request: the address in it is this page's Markdown copy, and the agent follows the instructions for it further down, with every setting Gitea's docs require.

## Or keep it private with Tailscale

The preview URL puts Gitea on the public internet, which suits something other people need to reach. For an app only you and your household use, your tailnet is the better home: Tailscale gives Gitea an HTTPS address that only your own devices, signed in to your Tailscale account, can open. Save a Tailscale auth key in the workspace's **Vars** pane as `TS_AUTHKEY`, and ask the agent:

```text
Set up Gitea on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/gitea.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
```

- On Plus and Pro, a Tailscale container runs beside Gitea, so it keeps its private address through workspace restarts and updates, and every app you set up this way gets an address of its own.
- On Hobby, Tailscale runs in the workspace beside Gitea; after a restart or an update, ask the agent to start both again.
- Anything other services have to reach, such as a webhook, still needs a public address. [Keep self-hosted apps private with Tailscale](https://envhaven.com/guides/self-host-privately-with-tailscale) covers both, and what Tailscale's free plan includes.

| At a glance |  |
| --- | --- |
| What it is | Developer tools and monitoring |
| License | MIT |
| Runs as | Docker (`docker.gitea.com/gitea`) or a native install |
| Memory | 1 GB (documented as typically sufficient for small teams/projects; no separate minimum/recommended split) ([docs](https://docs.gitea.com/)) |
| Plan that fits | Hobby or larger |
| Web port | 3000 |
| Documentation | [docs.gitea.com/installation/install-with-docker](https://docs.gitea.com/installation/install-with-docker) |

## What your agent takes care of

- **Installing it.** Gitea runs from the official image, `docker.gitea.com/gitea`, with its data in folders under `~/apps/gitea`, or without Docker on Hobby.
- **Putting it on an HTTPS address.** The workspace's preview URL serves it, and your own domain can too.
- **Locking it down first.** What Gitea's docs say to set before it faces the internet, below.
- **Telling you what to back up**: /data (Docker volume ./gitea:/data: repositories under /data/git/repositories, config and app data under /data/gitea, SQLite file if SQLite), /var/lib/gitea/{custom,data,log} and /etc/gitea/app.ini (binary install) and external MySQL/PostgreSQL database when not using SQLite ([docs](https://docs.gitea.com/administration/backup-and-restore)).

### The settings it needs behind a proxy

- [server] `ROOT_URL` (env GITEA__server__ROOT_URL in Docker): Public URL Gitea generates links and clone URLs from; set to the HTTPS address, with a trailing slash. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- Host and X-Forwarded-Proto request headers: The proxy must pass both so Gitea sees the real visited URL (PUBLIC_URL_DETECTION defaults to auto). ([docs](https://docs.gitea.com/administration/reverse-proxies))
- [server] `PUBLIC_URL_DETECTION`: auto (default): always use the Host header, plus X-Forwarded-Proto if present; never: always use ROOT_URL. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- [security] `REVERSE_PROXY_LIMIT` and `REVERSE_PROXY_TRUSTED_PROXIES`: How many proxy hops to trust for X-Forwarded-For/X-Real-IP, and which proxy addresses are trusted (default 127.0.0.0/8,::1/128), so the real client IP is logged. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- [session] `COOKIE_SECURE`: Forces the session cookie to HTTPS only; defaults to true when ROOT_URL is an HTTPS URL. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- WebSocket at /-/ws: Proxy must speak HTTP/1.1 and forward Upgrade and Connection headers, otherwise Gitea falls back to polling. ([docs](https://docs.gitea.com/administration/reverse-proxies))
- [server] `SSH_DOMAIN` and `SSH_PORT`: Host and port shown in SSH clone URLs; SSH_DOMAIN defaults to the domain of ROOT_URL. SSH git needs its own TCP port (container port 22 in the rootful image, 2222 in rootless; built-in server via START_SSH_SERVER). ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- [server] `DISABLE_SSH` and [repository] `DISABLE_HTTP_GIT`: HTTPS clone and push use the web port and are on by default (DISABLE_HTTP_GIT=false), so HTTPS clone works without SSH; DISABLE_SSH hides the SSH feature when no SSH port is reachable. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- HTTP(S) git over the proxy: Clone and pull over HTTPS need the proxy to present a full certificate chain. ([docs](https://docs.gitea.com/administration/reverse-proxies))

### Before it faces the internet

- The web installer is open to whoever reaches the port first until the install is finished; INSTALL_LOCK=true closes it (set it when pre-writing app.ini). ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- Docs list self-registration as disabled by default in the current version (DISABLE_REGISTRATION true); REQUIRE_SIGNIN_VIEW can hide the instance from anonymous visitors. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- SECRET_KEY is random per install and encrypts 2FA secrets; losing it makes that data unrecoverable. Back it up with app.ini. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- Run as a dedicated non-root account; Gitea rewrites that account's ~/.ssh/authorized_keys. ([docs](https://docs.gitea.com/))

## Things to ask next

Everything after the install is one more sentence to the agent. Some that come up:

- "Add a check for every site I run, and alert me on Telegram when one goes down."
- "Put it behind a login before anyone else finds the address."
- "Move Gitea to app.example.com." Add the domain on the dashboard's Domains page with a CNAME to `domains.envhaven.app`, and the agent changes Gitea's address settings to match.
- "Update Gitea to the latest release." It pulls the new image and recreates the container, data kept.

## Instructions for the agent

The agent reads these from the page's Markdown copy. They also work pasted on their own, if you would rather give them in your own words.

```text
Set up Gitea on this workspace and serve it at my preview URL.
- Where Docker has a daemon (Plus and Pro), use Docker Compose with the official image, docker.gitea.com/gitea, starting from the docs' compose file: https://docs.gitea.com/installation/install-with-docker. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- Keep the compose file in ~/apps/gitea and all of its data in folders there (bind mounts, not named volumes), with restart: unless-stopped on every service.
- This server has no firewall, so publish no port on its public IP, and drop host networking and privileged mode from the docs' compose file. Docker runs on the host: connect this workspace to the compose network and relay my preview URL's port to Gitea's port 3000.
- Without Docker (on Hobby, where Docker has no daemon), install it as its docs describe, with the prebuilt binary from dl.gitea.com, run as `gitea web` (Git >= 2.0 on the host), into ~/apps/gitea with its data, so it survives workspace updates; global installs and system paths do not. Run it in a tmux window named gitea, listening on 0.0.0.0:3000, and point my preview URL at port 3000.
- The preview URL terminates HTTPS in front of Gitea: serve plain HTTP on its port, and trust the forwarded headers the relay passes on.
- Set what "The settings it needs behind a proxy" lists on https://envhaven.com/self-host/gitea.md for the preview URL, as Gitea's docs describe for running behind a proxy; skip any that apply only when Gitea serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/gitea.md.
- When it answers at the preview URL, send me the link and tell me what to back up.
- If I asked for my tailnet instead of the preview URL, set Gitea up the same way but follow https://envhaven.com/guides/self-host-privately-with-tailscale.md for the network: no preview URL, no relay.
```

## What to know

- In Docker, Gitea's containers keep running when the workspace restarts or updates. The relay from the preview URL is a process in the workspace, so after a restart or an update, ask the agent to restore it.
- Without Docker, Gitea runs as a process in the workspace, so after a restart or an update, ask the agent to start it again.
- SSH git needs its own TCP port (compose maps host 222 to container 22; rootless maps 2222). An HTTP-only tunnel carries only the web port, so use HTTPS clone and set DISABLE_SSH. ([docs](https://docs.gitea.com/installation/install-with-docker))
- Large uploads and pushes over HTTP are bounded by the proxy body limit; the docs' own nginx example allows 512M, a 100 MB tunnel cap would stop larger pushes, LFS objects and release attachments (Gitea allows 2048 MB per release attachment). ([docs](https://docs.gitea.com/administration/reverse-proxies))
- Release attachment size default in Gitea. ([docs](https://docs.gitea.com/administration/config-cheat-sheet))
- Email needs an external SMTP server; sendmail is not usable in the official Docker image. ([docs](https://docs.gitea.com/administration/email-setup))
- Real-time notification counter uses a WebSocket; a proxy that drops Upgrade headers degrades to polling, not failure. ([docs](https://docs.gitea.com/administration/reverse-proxies))
- A workspace has one preview URL and one custom domain, both serving the same port, so it puts one app on a public address at a time.

## Without a workspace

The manual route, on a server you run:

1. Rent a Linux VPS, secure SSH, and create a user for the app.
2. Install Docker and write a compose file from the official image.
3. Put a reverse proxy in front (Caddy, nginx or Traefik), get certificates, and point a domain at the server.
4. Set the proxy settings listed above for that domain, and pass WebSocket upgrades through the proxy if the app uses them.
5. Keep the firewall closed except for the proxy, and schedule backups and updates.

Gitea's own [documentation](https://docs.gitea.com/installation/install-with-docker) covers each step for its install methods.

## Sources

Facts about Gitea come from its own documentation, checked on 2026-11-23:

- [docs.gitea.com/installation/install-with-docker](https://docs.gitea.com/installation/install-with-docker)
- [docs.gitea.com/installation/install-from-binary](https://docs.gitea.com/installation/install-from-binary)
- [docs.gitea.com](https://docs.gitea.com/)
- [docs.gitea.com/administration/config-cheat-sheet](https://docs.gitea.com/administration/config-cheat-sheet)
- [docs.gitea.com/administration/reverse-proxies](https://docs.gitea.com/administration/reverse-proxies)
- [docs.gitea.com/administration/email-setup](https://docs.gitea.com/administration/email-setup)
- [docs.gitea.com/administration/backup-and-restore](https://docs.gitea.com/administration/backup-and-restore)

## Keep reading

- [Self-host any app with your agent](https://envhaven.com/self-host)
- [Self-host Forgejo](https://envhaven.com/self-host/forgejo)
- [Self-host Uptime Kuma](https://envhaven.com/self-host/uptime-kuma)
- [Self-host Gatus](https://envhaven.com/self-host/gatus)
- [Self-host Grafana](https://envhaven.com/self-host/grafana)
- [AI agent hosting](https://envhaven.com/guides/ai-agent-hosting)

Source: https://envhaven.com/self-host/gitea
