This page documents the Forgejo configuration used in production.
Snapshot date: 2026-02
Stack: apps
Image: codeberg.org/forgejo/forgejo:1.21
Mode: Docker Swarm
1. Purpose
Forgejo provides:
- Self-hosted Git repositories
- SSH access for Git operations
- Web interface for repository management
- CI/CD integration (future use)
Forgejo is exposed via:
- HTTPS (via Nginx)
- SSH on port 2222
2. Network Architecture
Forgejo is attached to:
- internal (database access)
- web (optional, if required by architecture)
It connects internally to:
- PostgreSQL (data_postgres)
3. Port Exposure
Forgejo exposes:
| Port | Purpose |
|---|---|
| 3000 | Internal web UI (not public) |
| 22 | Internal SSH |
| 2222 | Published SSH port |
Swarm mapping:
*:2222 -> container:22
Verify:
sudo docker service inspect apps_forgejo
4. Database Configuration
Forgejo uses PostgreSQL.
Typical configuration:
- DB type: postgres
- Host: data_postgres
- Port: 5432
- Database: forgejo
- User: forgejo
- Password: injected via Docker secret
Secrets are mounted under:
/run/secrets/forgejo_db_password
Using _FILE pattern is recommended when supported.
5. Persistent Storage
Forgejo data directory:
/data
This must be backed by a persistent Docker volume.
Verify:
sudo docker volume ls
Inspect:
sudo docker volume inspect <forgejo_volume>
This directory contains:
- Repositories
- Configuration (app.ini)
- Attachments
Loss of this volume means total repository loss.
6. Nginx Reverse Proxy Integration
Forgejo is accessed via:
https://code.your-domain.com
Nginx forwards traffic internally to:
http://apps_forgejo:3000
Ensure:
- Correct proxy headers
- HTTPS enforced
- Large client body size if needed
7. SSH Access
Git SSH URL format:
ssh://git@your-domain.com:2222/organization/repository.git
Port 2222 must be open:
sudo ufw allow 2222
Verify:
sudo ss -tulpn | grep 2222
8. Initial Setup
On first run:
- Access web UI
- Configure database
- Create admin account
- Disable open registration (recommended)
9. Security Recommendations
- Disable open registration
- Enforce strong passwords
- Restrict SSH access if possible
- Backup repositories regularly
- Protect
/datavolume
10. Backup Strategy
Repositories are stored under:
/data/git/repositories
Backup example:
sudo tar -czf forgejo-backup.tar.gz /var/lib/docker/volumes/<forgejo_volume>/_data
Store backups externally.
11. Verify Service
Check service:
sudo docker service ls | grep forgejo
Check logs:
sudo docker service logs apps_forgejo
Check SSH connectivity:
ssh -p 2222 git@your-domain.com
- Architecture Overview
- System Hardware
- Operating System
- SSH Hardening
- Docker Installation
- Docker Swarm Configuration
- Network Architecture
- Stacks Deployment
- Reverse Proxy
- Certbot & Let's Encrypt
- TURN Server (Coturn)
- PostgreSQL Configuration
- MinIO Configuration
- Forgejo Configuration
- Mattermost Configuration
- Backup and Recovery
- Security Checklist