Gitea

From The Brainwrecked Wiki
Revision as of 09:31, 27 December 2019 by BrainwreckedTech (talk | contribs) (Server Settings: Added Nginx Reverse Proxy Configuration)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Prerequisites

Database
For storing repository data.

Wanted By

None

Installation

sudo pacman -Syu gitea

Configuration

Server Name

You can change the name that displays in every page title

/etc/gitea/app.ini
APP_NAME = <My Gitea Server>

Theme

Gitea comes with two themes.

/etc/gitea/app.ini
[ui]
DEFAULT_THEME = <arc-green|gitea>

Server Settings

There are 3 main types of server setup:

  1. Direct http access (listen on port 80/443)
  2. Proxied http access (default is to listen on port 3000)
  3. Proxied access using UNIX sockets
/etc/gitea/app.ini
[server]
PROTOCOL = <http|unix>
DOMAIN = <your.tld>
ROOT_URL = https://<your.tld>/
HTTP_ADDR = {<ip-address>|</path/to/socket>}
HTTP_PORT = {3000|80|<port>}
; Do not set this variable if PROTOCOL is set to 'unix'.
;LOCAL_ROOT_URL = https://<your.tld>/

Nginx Configuration for Reverse Proxy

server {
        listen                          80;
        listen                          [::]:80;
        server_name                     <your.tld>;
        return                          301 https://$host$request_uri;
}

server {
        listen                          443 ssl http2;
        listen                          [::]:443 ssl http2;
        server_name                     <your.tld>;

        ssl_certificate                 /etc/letsencrypt/live/<your.tld>/fullchain.pem;
        ssl_certificate_key             /etc/letsencrypt/live/<your.tld>/privkey.pem;
        ssl_trusted_certificate         /etc/letsencrypt/live/<your.tld>/chain.pem;

        # Let's Encrypt ACME challenge
        location ^~ /.well-known {
                allow                   all;
                alias                   /var/lib/letsencrypt/$host/.well-known;
                default_type            "text/plain";
                try_files               $uri =404;
        }

        location / {
                proxy_pass              http://unix:/run/gitea/gitea.socket;
        }
}

SSH Setup

If you have your system's SSH port set at something other than the default port 22, you probably want to enable Gitea's internal SSH server so it can listen in on port 22.

/etc/gitea/app.ini
[server]
START_SSH_SERVER = true

Set the SSH domain

/etc/gitea/app.ini
[server]
SSH_DOMAIN = <your.tld>

Large File Support

/etc/gitea/app.ini
[server]
LFS_START_SERVER = <false|true>
LFS_JWT_SECRET = <$(openssl rand -base64 33)>

Database Setup

MariaDB / MySQL

CREATE DATABASE `GITEA` DEFAULT CHARACTER SET `utf8mb4` COLLATE `utf8mb4_unicode_ci`;
CREATE USER `gitea`@`localhost` IDENTIFIED BY `<password>`;
GRANT ALL PRIVILEGES ON `GITEA`.* TO `gitea`@`localhost`;
FLUSH PRIVILEGES;
/etc/gitea/app.ini
[database]
DB_TYPE = mysql
HOST = {<ip-address>:<port>|/run/mysqld/mysqld.sock}
NAME = GITEA
USER = gitea
PASSWD = <password>
CHARSET = utf8mb4

PostgreSQL

CREATE DATABASE GITEA;
CREATE USER gitea WITH PASSWORD <password>;
GRANT ALL PRIVILEGES ON DATABASE GITEA TO gitea;
/etc/gitea/app.ini
[database]
DB_TYPE = postgresql
HOST = {<ip-address>:<port>|/run/postgresql/}
NAME = GITEA
USER = gitea
PASSWD = <password>

SQLite Setup

/etc/gitea/app.ini
[database]
DB_TYPE = sqlite
PATH = </path/to/lite.sql>

Redis Setup

Gitea is able to take advantage of Redis. It will give your server a noticeable bump in speed.

There are four sections that need changes in order to take advantage of Redis.

/etc/gitea/app.ini
[indexer]
ISSUE_INDEXER_QUEUE_TYPE = redis
; Choose one of the following
ISSUE_INDEXER_QUEUE_CONN_STR = "addrs=<ip-address>:<port> db=0"
ISSUE_INDEXER_QUEUE_CONN_STR = "unix=/run/redis/redis.sock db=0"

[cache]
ADAPTER = redis
; Choose one of the following
HOST = network:tcp,addr=<ip-address>:<port>,[password=<password>,]db=0,pool_size=100,idle_timeout=180
HOST = network:unix,addr=/run/redis/redis.sock,[password=<password>,]db=0,pool_size=100,idle_timeout=180

[session]
PROVIDER = redis
; Choose one of the following
PROVIDER_CONFIG = network:tcp,addr=<ip-address>:<port>,[password=<password>,]db=0,pool_size=100,idle_timeout=180
PROVIDER_CONFIG = network:unix,addr=/run/redis/redis.sock,[password=<password>,]db=0,pool_size=100,idle_timeout=180
; If you use session in https only, set to true.  Default is false.
COOKIE_SECURE = true

[task]
QUEUE_TYPE = redis
; Choose one of the following
QUEUE_CONN_STR = "addrs=<ip-address>:<port> db=0"
QUEUE_CONN_STR = "unix=/run/redis/redis.sock db=0"