Skip to content

Forgejo

Forgejo (GIT) Server.

Migrated to ansible collection

Use r_pufky.srv.forgejo.

Repository Management

Importing Git Repositories

You can import other git repositories including local and cloned ones:

# Push mirror to Forgejo.
cd my-repo-to-import
git push --mirror https://{IP}:3000/{USER}/{REPO}.git

As this is a mirror, you want to commit the git metadata and not just the files. The Forgejo repository is stored in forgejo_repository_root as a standard git repository. Importing this way sets up the Forgejo frontend database metadata for the project.

Mirrors

Forgejo mirrors can automatically manage upstream mirror syncs if setup to do so. This will also allow for local forking of those mirrors for individual use.

Create Mirror ➔ + ➔ New Migration

  • Migrate / Clone from URL: {REMOTE REPOSITORY URL}
  • Owner: {ORGANIZATION OWNER}
  • Repository Name: {SAME REPO NAME}
  • Visibility: Make Repository Private
  • Migration Type: This repository will be a mirror
  • Description: {DESCRIPTION}

Reverse Proxy

Forgejo should be run via a Reverse Proxy, allowing you to isolate and wrap connections in SSL. See NGINX for more details. See Base Proxy Control for basic proxy configuration.

Subdomains

This requires a hard IP resolution. Hairpin NAT / NAT reflection will result in the web front working but git pull/push/clones failing. This is due to the way Forgejo handles these requests with custom written handlers. Setup DNS resolution or add to hosts file.

/etc/nginx/conf.d/reverse_proxy.conf

0644 root:root

# Subdomain
server {
  listen                 443 ssl http2;
  server_name            gitea.{DOMAIN} gitea;

  location / {
    proxy_pass           http://gitea:3000;
    client_max_body_size 1024m;  # Expected max size of data in a git change.
  }
}

Subpath

/etc/nginx/conf.d/reverse_proxy.conf

0644 root:root

# Subpath
server {
  location /gitea/ {
    proxy_pass           http://gitea:3000/;
    client_max_body_size 1024m;  # Expected max size of data in a git change.
  }
}