By clicking or navigating this website site, you agree to allow our collection of information on Scaleway to offer you an optimal user experience and to keep track of statistics through cookies. Learn more about our Cookie Policy.

Setup self hosted git repository with Gitea

Gitea Overview

Gitea is a self-hosted Git service. It provides lightweight code hosting solution written in Go and published under the MIT license. The tool is a community managed fork of Gogs.

Git itself is a distributed version-control system for tracking changes in in files. The tool was originally invented by Linus Torvalds in 2005 to manage the development of the Linux kernel among other developers contributing to its code-base.

Unlike many other client-server systems, every Git directory on every computer contains the full repository with a complete history and version tracking, making it independent of network access or a central server.

Git was developed initially for software development, but it can be used to track changes in any kind of files.

5 . In a web browser go to http://<your_instance_ip>:3000/ to access the Gitea application:

6 . Click on Register to start the database initialization. Gitea supports SQLite which makes the application very lightweight and ideal for a self-hosted development Environment. If you require more performance, it is also possible to use MySQL/MariaDB or PostGreSQL.

7 . Choose SQLite as database type. Leave the other pre-filled settings as they are, they are already set to the required values and confirm the form.

8 . The installation is ready now and it is time to create the first user. Open http://<your_instance_ip>:3000/user/sign_up in a web browser and fill in the required parameters.

Important: The first user becomes automatically Admin of the Gitea instance.

9 . Once the form has been submitted, you are logged into your Gitea account:

You can now configure your profile and begin to host code on your instance.

Setting up a Nginx SSL/TLS reverse proxy

For increased security it is possible to recommended to configure NGINX reverse proxy](https://www.scaleway.com/en/docs/how-to-configure-nginx-reverse-proxy/) with TSL/SSL in front of the Gitea instance, it handles all requests sent from a client to the web interface and adds a layer of increased security and performance.

1 . Install Nginx:

apt install nginx

2 . Disable the default virtual host which has been configured during the installation of Nginx via the apt packet manager:

4 . Paste the following Nginx configuration block in the text editor. The proxy server redirects all incoming connections to the web server listening on port 80, to the local Gitea application, listening on port 3000.

13 . Certbot requests the certificate for the domain name indicated in the previous step. Decide wether you want to force HTTPS on all connections by pressing 1 or not, by pressing 2, followed by Enter:

14 . You can access Gitea via the Nginx Proxy now using an encrypted connection, by opening https://gitea.example.com in your web browser.

Disabling Port 3000 in the Firewall

1 . For increased security it is possible to block the access to port 3000 from the exterior to avoid direct connections to the Gitea application without passing through Nginx. Start by installing UFW as firewall on the instance: