{"id":1922,"date":"2026-09-05T10:23:10","date_gmt":"2026-09-05T04:53:10","guid":{"rendered":"https:\/\/cpanelfree.com\/blog\/how-to-host-forgejo-gitea-private-git-server-vps\/"},"modified":"2026-09-05T13:00:06","modified_gmt":"2026-09-05T07:30:06","slug":"how-to-host-forgejo-gitea-private-git-server-vps","status":"publish","type":"post","link":"https:\/\/cpanelfree.com\/blog\/how-to-host-forgejo-gitea-private-git-server-vps\/","title":{"rendered":"How to Self-Host Forgejo &amp; Gitea Lightweight Private Git Server on Ubuntu VPS"},"content":{"rendered":"<h2>Why Self-Host Private Git Repositories with Forgejo \/ Gitea?<\/h2>\n<p>While public GitHub and GitLab cloud platforms provide reliable version control, hosting proprietary commercial codebases, confidential client projects, and internal automation scripts on third-party SaaS platforms exposes organizations to policy changes, code scraping for AI training, and unexpected account suspensions. Additionally, enterprise self-hosted GitLab requires heavy computing resources (minimum 4GB to 8GB RAM).<\/p>\n<p><strong>Forgejo<\/strong> (the community-governed soft-fork of Gitea) is an ultra-lightweight, high-performance private Git server written in Go. Offering full feature parity with GitHub\u2014including pull requests, issue trackers, wiki pages, code reviews, container package registries, and native Actions CI\/CD workflows\u2014Forgejo runs smoothly on an affordable 1GB RAM cloud VPS while consuming less than 80MB of memory.<\/p>\n<p>In this technical tutorial, we will configure Forgejo on Ubuntu 24.04\/22.04 LTS backed by PostgreSQL with Docker Compose, configure SSH Git operations, and protect the web portal behind an Nginx reverse proxy with SSL encryption.<\/p>\n<h2>Step 1: Installing Docker Engine and Project Directory Setup<\/h2>\n<pre><code># Install Docker and prerequisite utilities\nsudo apt update &amp;&amp; sudo apt install -y curl nginx certbot python3-certbot-nginx\ncurl -fsSL https:\/\/get.docker.com | sudo sh\nsudo systemctl enable --now docker\n\n# Create project directory\nsudo mkdir -p \/var\/www\/forgejo\nsudo chown -R $USER:$USER \/var\/www\/forgejo\ncd \/var\/www\/forgejo<\/code><\/pre>\n<h2>Step 2: Writing Production Docker Compose with PostgreSQL<\/h2>\n<p>Create <code>\/var\/www\/forgejo\/docker-compose.yml<\/code>:<\/p>\n<pre><code>services:\n  db:\n    image: postgres:16-alpine\n    container_name: forgejo_db\n    restart: always\n    environment:\n      POSTGRES_USER: forgejo_user\n      POSTGRES_PASSWORD: UltraStrongGitDbPass2026!\n      POSTGRES_DB: forgejo_db\n    volumes:\n      - postgres_data:\/var\/lib\/postgresql\/data\n\n  server:\n    image: codeberg.org\/forgejo\/forgejo:7.0\n    container_name: forgejo_server\n    restart: always\n    environment:\n      - USER_UID=1000\n      - USER_GID=1000\n      - FORGEJO__database__DB_TYPE=postgres\n      - FORGEJO__database__HOST=db:5432\n      - FORGEJO__database__NAME=forgejo_db\n      - FORGEJO__database__USER=forgejo_user\n      - FORGEJO__database__PASSWD=UltraStrongGitDbPass2026!\n      - FORGEJO__server__ROOT_URL=https:\/\/git.example.com\n      - FORGEJO__server__SSH_PORT=2222\n      - FORGEJO__server__SSH_LISTEN_PORT=22\n    ports:\n      - \"127.0.0.1:3000:3000\"\n      - \"2222:22\"\n    volumes:\n      - forgejo_data:\/data\n    depends_on:\n      - db\n\nvolumes:\n  postgres_data:\n  forgejo_data:<\/code><\/pre>\n<p>Start the container fleet: <code>docker compose up -d<\/code>.<\/p>\n<h2>Step 3: Nginx Reverse Proxy with SSL Encryption<\/h2>\n<p>Create <code>\/etc\/nginx\/sites-available\/git.example.com<\/code>:<\/p>\n<pre><code>server {\n    listen 80;\n    server_name git.example.com;\n\n    client_max_body_size 200M;\n\n    location \/ {\n        proxy_pass http:\/\/127.0.0.1:3000;\n        proxy_http_version 1.1;\n        proxy_set_header Host $host;\n        proxy_set_header X-Real-IP $remote_addr;\n        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\n        proxy_set_header X-Forwarded-Proto $scheme;\n    }\n}<\/code><\/pre>\n<p>Enable the site and issue an SSL certificate:<\/p>\n<pre><code>sudo ln -s \/etc\/nginx\/sites-available\/git.example.com \/etc\/nginx\/sites-enabled\/\nsudo nginx -t &amp;&amp; sudo systemctl reload nginx\nsudo certbot --nginx -d git.example.com<\/code><\/pre>\n<h2>Setting Up Forgejo Actions CI\/CD with Act Runner<\/h2>\n<p>Forgejo includes native compatibility with GitHub Actions workflows. Deploy the lightweight <code>act_runner<\/code> daemon on your VPS to execute automated testing, build, and deployment pipelines:<\/p>\n<pre><code># Download act_runner binary\ncurl -L https:\/\/code.forgejo.org\/forgejo\/runner\/releases\/download\/v3.4.0\/act_runner-3.4.0-linux-amd64 -o \/usr\/local\/bin\/act_runner\nchmod +x \/usr\/local\/bin\/act_runner\n\n# Register runner with your Forgejo instance\nact_runner register --instance https:\/\/git.example.com --token &lt;YOUR_RUNNER_REGISTRATION_TOKEN&gt; --no-interactive\n\n# Start runner daemon\nact_runner daemon<\/code><\/pre>\n<h2>Automating Daily Git Repository Backups<\/h2>\n<p>Create nightly atomic backups using the built-in Forgejo CLI dump command: <code>docker exec -t forgejo_server su - git -c \"gitea dump -c \/data\/gitea\/conf\/app.ini\"<\/code>.<\/p>\n<h2>Configuring Built-In Container &amp; Package Registry in Forgejo<\/h2>\n<p>Forgejo includes an integrated OCI Docker container registry and language package manager (NPM, PyPI, Maven, Composer) out of the box, allowing developers to publish private Docker images and software packages directly to their self-hosted Git server without paying for Docker Hub Pro:<\/p>\n<pre><code># Authenticate Docker client with self-hosted Forgejo registry\ndocker login git.example.com -u your_username -p your_access_token\n\n# Tag and push container image\ndocker tag my-web-app:latest git.example.com\/org\/my-web-app:1.0.0\ndocker push git.example.com\/org\/my-web-app:1.0.0<\/code><\/pre>\n<h2>Forgejo vs Self-Hosted GitLab Resource Comparison<\/h2>\n<table style=\"width: 100%;border-collapse: collapse;margin: 20px 0;border: 1px solid #334155\">\n<thead>\n<tr style=\"background-color: #0f172a;color: #38bdf8\">\n<th style=\"padding: 12px;border: 1px solid #334155\">Metric \/ Feature<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">Forgejo \/ Gitea (Go)<\/th>\n<th style=\"padding: 12px;border: 1px solid #334155\">GitLab Community (Ruby\/Java)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Minimum RAM Requirement<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>512 MB to 1 GB RAM<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">4 GB to 8 GB RAM<\/td>\n<\/tr>\n<tr style=\"background-color: #0f172a;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Startup Boot Time<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>~2 seconds<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">~2 to 4 minutes<\/td>\n<\/tr>\n<tr style=\"background-color: #1e293b;color: #f8fafc\">\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>Built-in CI\/CD Workflows<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\"><strong>GitHub Actions Syntax Compatible<\/strong><\/td>\n<td style=\"padding: 10px;border: 1px solid #334155\">Custom .gitlab-ci.yml syntax<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Configuring SSH Key Authentication &amp; Deploy Keys in Forgejo<\/h2>\n<p>Forgejo supports cryptographic Ed25519 and RSA public keys for secure command-line Git operations (push\/pull). Developers can configure global user SSH keys or repository-specific read-only <strong>Deploy Keys<\/strong> for automated CI\/CD deployment pipelines:<\/p>\n<pre><code># Generate dedicated deploy key for web server\nssh-keygen -t ed25519 -C \"forgejo-deploy@example.com\" -f \/var\/www\/.ssh\/forgejo_deploy\n\n# In Forgejo Web UI:\n# Navigate to Repository &gt; Settings &gt; Deploy Keys &gt; Add Deploy Key\n# Paste \/var\/www\/.ssh\/forgejo_deploy.pub<\/code><\/pre>\n<h2>Forgejo Webhook Integration with Slack &amp; Discord<\/h2>\n<p>Keep development teams synchronized by configuring native webhooks under <strong>Repository &gt; Settings &gt; Webhooks<\/strong>. Select Discord or Slack to receive instant notifications on push commits, opened pull requests, issue mentions, and release tag creation.<\/p>\n<h2>Forgejo High-Availability &amp; Disaster Recovery Best Practices<\/h2>\n<ul>\n<li><strong>Automate SQLite\/PostgreSQL Dumps:<\/strong> Schedule nightly <code>pg_dump<\/code> cron jobs to capture all issue trackers, commit metadata, and user accounts.<\/li>\n<li><strong>Mirror Repositories to GitHub:<\/strong> Use Forgejo&#8217;s automated push-mirroring feature to synchronize internal repositories to external GitHub organizations continuously.<\/li>\n<\/ul>\n<div style=\"background-color: #0f172a;border-left: 4px solid #38bdf8;padding: 18px 24px;margin: 30px 0;border-radius: 8px\">\n<h3 style=\"color: #38bdf8;margin-top: 0\">Recommended Related Technical Guides<\/h3>\n<ul style=\"margin-bottom: 0;color: #cbd5e1\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-automate-git-deployment-github-actions-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Automating Continuous Deployments with Git &amp; SSH<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-secure-linux-vps-fail2ban-ufw-ssh\/\" style=\"color: #38bdf8;text-decoration: underline\">Hardening SSH &amp; Firewall Ports on Linux Cloud VPS<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-uptime-kuma-server-monitoring-docker-vps\/\" style=\"color: #38bdf8;text-decoration: underline\">Monitoring Private Git Server Uptime with Uptime Kuma<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 28px;border-radius: 12px;margin: 35px 0;text-align: center\">\n<h3 style=\"color: #ffffff;margin-top: 0;font-size: 22px\">Self-Host Private Git Repositories on CpanelFree<\/h3>\n<p style=\"color: #e0f2fe;font-size: 15px;max-width: 650px;margin: 0 auto 18px auto\">Take full control of your source code and CI\/CD pipelines with high-speed NVMe cloud VPS servers and 100% free hosting options.<\/p>\n<p>  <a href=\"https:\/\/cpanelfree.com\/\" style=\"background-color: #ffffff;color: #0284c7;font-weight: 700;padding: 12px 28px;border-radius: 8px;text-decoration: none;display: inline-block\">Get Free Cloud Hosting Today &rarr;<\/a>\n<\/div>\n<div style=\"border-radius: 12px;padding: 24px;margin: 24px 0\">\n<h3 style=\"color: #38bdf8;margin-top: 0\">Automated CI\/CD Pipelines with Forgejo Actions and Runner Setup<\/h3>\n<p>Forgejo includes native compatibility with GitHub Actions workflow syntax through Forgejo Actions. By deploying lightweight Docker-based runner daemons, development teams execute continuous integration tests, security linting, and automated deployments directly within their private self-hosted infrastructure:<\/p>\n<pre><code class=\"language-yaml\"># .forgejo\/workflows\/ci.yaml - Automated Build and Test Pipeline\nname: Forgejo Continuous Integration\non:\n  push:\n    branches: [ main, develop ]\n  pull_request:\n    branches: [ main ]\n\njobs:\n  test:\n    runs-on: docker\n    container:\n      image: node:20-alpine\n    steps:\n      - name: Check out repository code\n        uses: actions\/checkout@v4\n      - name: Install dependencies and execute test suite\n        run: |\n          npm ci\n          npm run lint\n          npm test -- --coverage<\/code><\/pre>\n<h4 style=\"color: #38bdf8\">Enterprise Backup Automation and Disaster Recovery<\/h4>\n<p>Maintain resilient snapshot workflows for Git repositories, issue trackers, LFS blobs, and SQLite\/PostgreSQL databases using Forgejo built-in command-line backup utilities:<\/p>\n<pre><code class=\"language-bash\"># Execute full backup archive containing database, git repositories, and configs\ndocker exec -u git forgejo-server forgejo dump -c \/data\/gitea\/conf\/app.ini --file \/data\/backup.zip\n\n# Encrypt and synchronize backup archive to off-site secure object storage\ngpg --symmetric --batch --passphrase \"$BACKUP_SECRET\" \/data\/backup.zip\nrclone copy \/data\/backup.zip.gpg s3:enterprise-git-backups\/forgejo\/<\/code><\/pre>\n<p>Coupling Forgejo with containerized SSH passthrough and automated off-site synchronization delivers a sovereign, high-throughput DevOps hub with zero third-party platform lock-in.<\/p>\n<\/div>\n<div style=\"border-left: 4px solid #38bdf8;border-radius: 8px;padding: 20px;margin: 30px 0\">\n<h3 style=\"margin-top: 0;color: #38bdf8;font-size: 18px;display: flex;align-items: center\">\n        <span style=\"margin-right: 8px\">\ud83d\udd17<\/span> Recommended Related Technical Guides:<br \/>\n    <\/h3>\n<ul style=\"margin: 10px 0 0 0;padding-left: 20px;line-height: 1.8\">\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-host-website-free-forever-guide\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Host a Website for Free Forever: Complete Beginner Guide (2026)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/free-wordpress-hosting-softaculous-installer\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">Top 5 Free WordPress Hosting Services with 1-Click Softaculous Installer<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-backup-linux-vps-to-cloud-storage-s3-rclone\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Automatically Backup Your Linux VPS to Cloud Storage (S3 \/ Rclone Guide)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/blog\/how-to-connect-custom-domain-free-web-hosting\/\" style=\"color: #38bdf8;text-decoration: none;font-weight: 600\">How to Connect a Custom Domain to Free Web Hosting (Complete 2026 Guide)<\/a><\/li>\n<li><a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"color: #10b981;text-decoration: none;font-weight: 600\">Explore $0 Free cPanel Web Hosting Plans (NVMe SSD, AutoSSL)<\/a><\/li>\n<\/ul>\n<\/div>\n<div style=\"background: linear-gradient(135deg, rgba(6, 182, 212, 0.15) 0%, rgba(59, 130, 246, 0.15) 100%);border-radius: 12px;padding: 25px;margin: 30px 0;text-align: center\">\n<h3 style=\"color: #38bdf8;margin-top: 0;font-size: 20px\">Deploy Fast, Reliable Web Hosting on CpanelFree<\/h3>\n<p style=\"color: #94a3b8;font-size: 14px;line-height: 1.6;max-width: 600px;margin: 0 auto 15px\">\n        Get genuine cPanel control, unmetered NVMe SSD storage, and free AutoSSL at $0 cost forever.\n    <\/p>\n<p>    <a href=\"https:\/\/cpanelfree.com\/#plans\" style=\"display: inline-block;background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);color: #ffffff;padding: 10px 22px;border-radius: 6px;text-decoration: none;font-weight: bold;font-size: 14px\">Claim Free Hosting Account<\/a>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Why Self-Host Private Git Repositories with Forgejo \/ Gitea? While public GitHub and GitLab cloud platforms provide reliable version control, hosting proprietary commercial codebases, confidential client projects, and internal automation scripts on third-party SaaS platforms exposes organizations to policy changes, code scraping for AI training, and unexpected account suspensions. Additionally, enterprise self-hosted GitLab requires heavy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2518,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[],"class_list":["post-1922","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-developer-stacks"],"_links":{"self":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1922","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/comments?post=1922"}],"version-history":[{"count":5,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions"}],"predecessor-version":[{"id":2318,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/posts\/1922\/revisions\/2318"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media\/2518"}],"wp:attachment":[{"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/media?parent=1922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/categories?post=1922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cpanelfree.com\/blog\/wp-json\/wp\/v2\/tags?post=1922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}