Self-host Forgejo

Self-hosted software forge: Git hosting with issues, pull requests, wikis, kanban boards, releases and a package registry. Run your own Forgejo 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 Forgejo 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 Forgejo 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:

Set up Forgejo on this workspace and give me the link. Follow https://envhaven.com/self-host/forgejo.md

Then open the link it sends and create your Forgejo 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 Forgejo’s docs require.

Or keep it private with Tailscale

The preview URL puts Forgejo 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 Forgejo 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:

Set up Forgejo on my tailnet instead of the preview URL. Follow https://envhaven.com/self-host/forgejo.md and https://envhaven.com/guides/self-host-privately-with-tailscale.md
  • On Plus and Pro, a Tailscale container runs beside Forgejo, 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 Forgejo; 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 covers both, and what Tailscale’s free plan includes.
At a glance
What it isDeveloper tools and monitoring
LicenseGPL-3.0-or-later
Runs asDocker (codeberg.org/forgejo/forgejo) or a native install
MemoryNot documented
Plan that fitsHobby or larger
Web port3000
Documentationforgejo.org/docs/latest/admin/installation/docker/

What your agent takes care of

  • Installing it. Forgejo runs from the official image, codeberg.org/forgejo/forgejo, with its data in folders under ~/apps/forgejo, 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 Forgejo’s docs say to set before it faces the internet, below.
  • Telling you what to back up: /data (Docker volume ./forgejo:/data), /var/lib/forgejo and /etc/forgejo/app.ini (binary install) and SQLite file in the data folder, or an external MySQL/MariaDB/PostgreSQL database (docs).

The settings it needs behind a proxy

  • [server] ROOT_URL (Docker env FORGEJO__server__ROOT_URL): Public URL used for generated links and clone URLs; set it to the HTTPS address. (docs)
  • FORGEJO__[SECTION]__[KEY] environment variables: Container image maps env vars onto app.ini keys, so ROOT_URL, DOMAIN and the rest can be set without editing app.ini. (docs)
  • [server] ROOT_URL with HTTPS: Switch ROOT_URL to https:// so generated links use HTTPS when the proxy terminates TLS. (docs)
  • [server] DOMAIN: Server domain, default localhost; ROOT_URL is built from it unless overridden. (docs)
  • [security] REVERSE_PROXY_LIMIT and REVERSE_PROXY_TRUSTED_PROXIES: How many proxy hops and which proxy addresses (default 127.0.0.0/8,::1/128) are trusted for X-Forwarded-For/X-Real-IP. (docs)
  • [session] COOKIE_SECURE: Forces the session cookie to HTTPS only; defaults to true when ROOT_URL is an HTTPS URL. (docs)
  • Proxy headers (Host, X-Forwarded-For, X-Forwarded-Proto, Upgrade, Connection): The docs’ nginx sample forwards these to Forgejo; it also sets merge_slashes off so URL-encoded slashes survive. (docs)
  • [server] SSH_DOMAIN and SSH_PORT: Host and port shown in SSH clone URLs (SSH_DOMAIN defaults to DOMAIN, SSH_PORT to 22). SSH git needs its own TCP port; the Docker example maps host 222 to container 22. (docs)
  • [server] DISABLE_SSH and [repository] DISABLE_HTTP_GIT: HTTP(S) git is on by default (DISABLE_HTTP_GIT=false) and uses the web port, so HTTPS clone works without SSH; DISABLE_SSH hides the SSH feature when no SSH port is reachable. (docs)

Before it faces the internet

  • The first account registered through the web UI becomes administrator, so finish setup before announcing the URL. (docs)
  • The installation page stays reachable until INSTALL_LOCK is true. (docs)
  • Self-registration is open by default (DISABLE_REGISTRATION false); the docs recommend enabling a captcha for open registration. (docs)
  • Recommendation for instances with open registration. (docs)
  • SECRET_KEY encrypts 2FA secrets, webhook credentials and Actions secrets; losing it makes them unreadable. Back up app.ini. (docs)

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 Forgejo to app.example.com.” Add the domain on the dashboard’s Domains page with a CNAME to domains.envhaven.app, and the agent changes Forgejo’s address settings to match.
  • “Update Forgejo 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.

Set up Forgejo 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, codeberg.org/forgejo/forgejo, starting from the docs' compose file: https://forgejo.org/docs/latest/admin/installation/docker/. If `docker compose` is missing, install the Compose plugin into ~/.docker/cli-plugins first.
- Keep the compose file in ~/apps/forgejo 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 Forgejo's port 3000.
- Without Docker (on Hobby, where Docker has no daemon), install it as its docs describe, with the prebuilt binary from its releases, run as `forgejo web` (git and git-lfs installed on the host; no language runtime for the prebuilt binary), into ~/apps/forgejo with its data, so it survives workspace updates; global installs and system paths do not. Run it in a tmux window named forgejo, listening on 0.0.0.0:3000, and point my preview URL at port 3000.
- The preview URL terminates HTTPS in front of Forgejo: 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/forgejo.md for the preview URL, as Forgejo's docs describe for running behind a proxy; skip any that apply only when Forgejo serves HTTPS itself.
- Before the preview URL serves it, apply what "Before it faces the internet" lists on https://envhaven.com/self-host/forgejo.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 Forgejo 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, Forgejo’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, Forgejo 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 (Docker example maps host 222 to container 22). An HTTP-only tunnel carries only the web port, so use HTTPS clone and set DISABLE_SSH. (docs)
  • Per-file upload limits: 50 MB for repository file uploads and 2048 MB for issue/PR attachments by default; the docs’ nginx sample raises client_max_body_size to 512M. A 100 MB tunnel cap would cut off larger uploads and pushes first. (docs)
  • Nginx body limit in the documented reverse-proxy sample. (docs)
  • Email (registration confirmation, notifications) needs an external SMTP server or sendmail; authenticated SMTP requires TLS (STARTTLS on port 587 or SMTPS on 465). (docs)
  • SMTP authentication is refused over cleartext connections. (docs)
  • 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.

Forgejo’s own documentation covers each step for its install methods.

Sources

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