Gitea, Forgejo and GitLab Community Edition are the three most practical self hosted alternatives to GitHub, and the shortest working path is to run one of them in Docker behind a reverse proxy with HTTPS. That gets you repositories, issues, pull requests and webhooks on hardware you control, with no per-seat bills and no third party holding your code. Everything below uses that same shape of setup, with notes on where the three projects differ.
What You'll Need
- A server or spare machine. A home NAS, a small mini PC, a VPS or a Raspberry Pi all work for a personal or small team instance; a Pi is slow for large repositories and CI jobs, so size up if you plan to store big binaries.
- A Linux distribution you are comfortable updating (Debian, Ubuntu, Fedora or similar). Almost every guide and package assumes Linux.
- Docker Engine and the Docker Compose plugin, or the plain native package for your distro if you prefer no containers.
- A domain or subdomain, for example git.yourdomain.com, with the ability to add DNS records. Self signed certificates cause endless Git client errors, so plan for a real one.
- Ports 80 and 443 reachable from the internet if you want remote access, or a VPN such as WireGuard or Tailscale if you only need internal access.
- A backup destination separate from the server itself. Git history is only as safe as your last tested restore.
- Basic command line comfort: editing a file, running commands over SSH, reading logs.
Step-by-Step
- Pick the platform. Gitea and its community fork Forgejo are lightweight, fast, and run comfortably on modest hardware with a familiar GitHub-like interface. GitLab Community Edition is far heavier, needs substantially more RAM and disk, but bundles a full CI/CD pipeline, container registry and more project management tools. Choose Gitea or Forgejo for a personal instance or small team; choose GitLab CE if you specifically need its integrated pipelines and can afford the resources.
- Prepare the host. Update the system, create a non-root user for administration, and enable a firewall allowing SSH, HTTP and HTTPS only. If the server is internet facing, disable password logins for SSH and use keys.
- Set up DNS and the reverse proxy. Point your subdomain at the server's IP address. Run a reverse proxy such as Caddy, Nginx or Traefik so the Git service sits behind HTTPS on port 443. Caddy will obtain and renew certificates automatically if the domain resolves correctly and ports 80 and 443 are open. Reverse proxy labels and config syntax change between versions, so check the current documentation for whichever proxy you pick.
- Create the data directories. Make a folder for persistent data and one for configuration, owned by the user the container will run as. Everything that matters lives there: repositories, database, attachments and the app configuration file. If those volumes are not mounted persistently, a container update wipes your instance.
- Bring up the service with Docker Compose. A typical stack is three containers: the Git application, a database (PostgreSQL or MariaDB), and optionally a cache. Write a compose file that mounts your data folders and passes environment variables for the database connection, the external URL and the SSH port. Run it, then check the logs for startup errors before going further.
- Complete the web installer. Open your subdomain in a browser. The first-run installer asks for database settings, the site URL, and an administrator account. Use the database service name from your compose file as the host, set the site URL to your HTTPS address exactly, and create the admin user immediately so nobody else can claim it. Lock the installer afterwards if the app offers that option.
- Configure SSH access. Git over HTTPS works out of the box, but SSH is more convenient. Either expose the container's SSH port on the host and tell users to connect on that port, or run the app directly on the host so it can use the standard SSH port. Whichever you choose, document the exact clone URL pattern for your users, because a wrong port is the single most common source of clone failures.
- Migrate from GitHub. Both Gitea and Forgejo have a migration tool that pulls a repository, its issues, pull requests, labels and milestones from a URL using an access token. Create a token on GitHub with read access to the repositories you want, then use the migration option in the web interface for each repository. For a straight code-only copy, a mirror clone followed by a push also works. Verify that branch protection, default branches and tags came across, since not every setting migrates.
- Invite your team and set permissions. Create organisations and teams, assign repository roles, and enable two-factor authentication for admin accounts. Set the registration option to closed or invite-only unless you want a public instance.
- Wire up notifications and webhooks. Add email settings so password resets and issue notifications leave the server. Point webhooks at your chat tool or CI runner so pushes trigger builds. Test one webhook manually from the repository settings page.
- Automate backups and test a restore. Dump the database on a schedule, and copy the repository and attachment folders elsewhere. A database dump alone is not enough, and the data folder alone is not enough either. Restore once into a scratch environment to prove the backup is usable.
- Schedule updates. Pull new container images on a regular cadence, read the release notes for migration steps, and take a backup immediately before upgrading. Confirm the new version starts and that a clone and push still work.
Common Mistakes
The most frequent failure is skipping persistent volumes, so an upgrade or a recreated container leaves an empty instance. The second is misconfiguring the external URL: if it says http or uses an internal hostname, generated clone links, webhook payloads and password reset emails all break. Third, people expose the database port to the internet instead of keeping it on the internal Docker network. Fourth, they use self signed certificates and then blame Git for certificate errors. Fifth, they migrate code but forget access tokens, deploy keys and CI secrets, which do not transfer and must be recreated. Finally, many instances run for months with no tested backup, which is the same as having none.
Tips
Keep the database and the application on the same compose network and never publish the database port. Use a dedicated non-root user inside containers where the image supports it. Run a liveness check against the web endpoint so you learn about downtime before your users do. If you host at home, put the service behind a VPN rather than opening ports, and keep the reverse proxy on the same machine to reduce complexity. Write a one-page runbook covering how to start, stop, back up and restore the instance, because in six months you will not remember the commands. For teams, mirror important GitHub repositories into your instance so a GitHub outage or account problem never blocks a release. Consider object storage for large binary assets if repositories grow heavy.
Troubleshooting
Clones fail with a certificate error. Your proxy is serving an invalid or self signed certificate. Check the certificate chain and that the site URL matches the domain exactly.
Permission denied over SSH. The SSH port in the clone URL does not match the exposed port, or the user's public key is not added to their profile. Compare the clone URL with your compose port mapping.
The page loads but assets are broken or logins loop. The configured external URL differs from the address in the browser, usually a missing HTTPS or a different subdomain. Fix it in the configuration file and restart.
The container restarts repeatedly. Read the logs; it is nearly always a database connection problem, a wrong password, or a data folder owned by the wrong user. Correct the permissions and restart.
Push rejected as too large. Check the reverse proxy body size limit and the application's upload limit; both must allow the push size you need.
Migration stalls or misses issues. The token probably lacks the right scopes, or the repository is private. Regenerate the token with broader read access and retry.
If that did not work, start from a clean compose file with the documented example configuration, back up your data first, and bring the service up without the reverse proxy to confirm it works on localhost. Then add the proxy back one layer at a time.
Frequently Asked Questions
Is a self hosted alternative as feature complete as GitHub?
No. Core Git hosting, issues, pull requests and webhooks are well covered, but the surrounding ecosystem, hosted Actions marketplace and integrated code search differ. Expect to add separate tools for CI, package registries or code scanning.
How much hardware does it need?
Requirements vary widely by platform and repository size. Gitea and Forgejo run on very modest hardware; GitLab CE needs considerably more memory and disk. Check the official documentation for current minimums rather than guessing.
Can I migrate my issues and pull requests from GitHub?
Gitea and Forgejo can import issues, pull requests, labels and milestones using an access token. Some metadata, such as CI configuration and secrets, does not transfer and must be recreated by hand.
Do I need a domain name?
For a public or team instance, yes in practice. A proper domain lets you use trusted HTTPS certificates and stable clone URLs. For private use only, a VPN with an internal hostname can work.
Who is responsible for security patches?
You are. Subscribe to the project's release announcements, apply updates regularly, and keep the host, proxy and database patched as well.
Can several people share one instance?
Yes. Organisations and teams handle permissions and are part of every mainstream option. For a small group the lightweight platforms are usually the better fit.