How to Self-Host Forgejo on Contabo (2026 Guide)
Forgejo is a popular open-source, self-hosted Git service that enables developers to manage their code repositories effectively. This guide will show you how to install and configure Forgejo on a Contabo VPS, ensuring that you maximize your serverโs performance while keeping everything secure.
Why Choose Contabo for Self-Hosting?
Contabo offers competitive pricing and robust infrastructure, making it an attractive option for self-hosting applications like Forgejo. Hereโs a quick comparison of some popular VPS providers:
| Provider | Price (EUR/USD) | Features | Performance |
|---|---|---|---|
| Contabo VPS | 5.99 EUR/mo | SSD storage, high bandwidth | High |
| Hetzner Cloud | 4.15 EUR/mo | Reliable performance, easy setup | Medium |
| DigitalOcean | 6 USD/mo | Simple interface, scalable options | High |
| Vultr | 6 USD/mo | Wide server locations, user-friendly | High |
| Linode (Akamai) | 5 USD/mo | Excellent support, fast storage | High |
For detailed comparisons, check our full VPS comparison.
Prerequisites
Before you start, ensure you have:
- A Contabo VPS with at least 2 GB RAM (recommended).
- Basic knowledge of SSH and command line interface.
- A domain name to link to your Forgejo instance (optional).
Step 1: Setting Up Your Contabo VPS
-
Log in to your Contabo VPS:
- Use SSH to connect:
ssh root@your_vps_ip
- Use SSH to connect:
-
Update your system:
apt update && apt upgrade -y -
Install essential packages:
apt install curl git -y
Step 2: Install Docker
Forgejo runs efficiently using Docker. To install Docker, follow these steps:
-
Install Docker:
curl -fsSL https://get.docker.com -o get-docker.sh sh get-docker.sh -
Add your user to the Docker group (optional for non-root usage):
usermod -aG docker $USER -
Verify Docker installation:
docker --version
Step 3: Deploy Forgejo Using Docker
-
Create a Docker network:
docker network create forgejo -
Create a directory for Forgejo data:
mkdir -p /opt/forgejo/{data,logs} -
Create a
docker-compose.ymlfile:nano /opt/forgejo/docker-compose.ymlAdd the following content to your
docker-compose.ymlfile:version: '3' services: forgejo: image: forgejo/forgejo:latest restart: always networks: - forgejo ports: - "3000:3000" # Forgejo web interface volumes: - ./data:/data - ./logs:/logs environment: - SECRET_KEY_BASE=your_secret_key_base - APP_URL=http://your_domain_or_ip:3000Replace
your_secret_key_basewith a secure key generated using:openssl rand -hex 32
Step 4: Start Forgejo
-
Navigate to the Forgejo directory:
cd /opt/forgejo -
Run the Forgejo container:
docker-compose up -d -
Check the logs to ensure it started successfully:
docker-compose logs -f
Step 5: Accessing Forgejo
-
Open your web browser and navigate to:
http://your_domain_or_ip:3000 -
You will be greeted by the Forgejo setup page. Follow the prompts to create your admin account.
FAQs
How secure is Forgejo when self-hosting on Contabo?
Self-hosting Forgejo on Contabo is relatively secure if best practices are followed. Always use a strong secret key and enable HTTPS for your Forgejo instance. You can use a reverse proxy like Nginx to handle SSL termination. Regularly update your Docker images and the Forgejo application to patch vulnerabilities.
What are the main advantages of using Forgejo?
Forgejo offers several advantages including a user-friendly interface for managing repositories, issue tracking, and CI/CD integration. Additionally, being self-hosted means you have full control over your data and repositories, which is paramount for developers concerned about privacy and data security.
How do I back up my Forgejo data?
Backing up your Forgejo data is crucial to prevent data loss. Since Forgejo uses Docker, you can back up your data by creating a tarball of the data directory. Execute the following command:
tar -czvf forgejo_backup.tar.gz /opt/forgejo/data
Consider automating this backup process through cron jobs to ensure regular backups without manual intervention.
Following this guide should lead to a successful setup of Forgejo on your Contabo VPS. If youโre looking to explore more self-hosted solutions, visit the r/selfhosted subreddit or the awesome-selfhosted GitHub repository for additional resources. Happy hosting!