Skip to content

Gitea and NGinx Setup Guide

Kernel: Please check to make sure these options are set correctly.

 *   CONFIG_CGROUP_FREEZER:      is not set when it should be.
 *   CONFIG_VETH:        is not set when it should be.
 *   CONFIG_BRIDGE_NETFILTER:    is not set when it should be.
 *   CONFIG_IP_NF_TARGET_MASQUERADE:     is not set when it should be.
 *   CONFIG_NETFILTER_XT_MATCH_ADDRTYPE:         is not set when it should be.
 *   CONFIG_NETFILTER_XT_MATCH_IPVS:     is not set when it should be.
 *   CONFIG_NETFILTER_XT_MARK:   is not set when it should be.
 *   CONFIG_CGROUP_PERF:         is not set when it should be.
 *   CONFIG_IP_NF_TARGET_REDIRECT:       is not set when it should be.
 *   CONFIG_IP_VS:       is not set when it should be.
 *   CONFIG_IP_VS_NFCT:  is not set when it should be.
 *   CONFIG_IP_VS_PROTO_TCP:     is not set when it should be.
 *   CONFIG_IP_VS_PROTO_UDP:     is not set when it should be.
 *   CONFIG_IP_VS_RR:    is not set when it should be.
 *   CONFIG_VXLAN:       is not set when it should be.
 *   CONFIG_CRYPTO_SEQIV:        is not set when it should be.
 *   CONFIG_INET_ESP:    is not set when it should be.
 *   CONFIG_IPVLAN:      is not set when it should be.
 *   CONFIG_MACVLAN:     is not set when it should be.
 *   CONFIG_DUMMY:       is not set when it should be.
 *   CONFIG_NF_NAT_FTP:  is not set when it should be.
 *   CONFIG_NF_CONNTRACK_FTP:    is not set when it should be.
 *   CONFIG_NF_NAT_TFTP:         is not set when it should be.
 *   CONFIG_NF_CONNTRACK_TFTP:   is not set when it should be.

Install docker requirements / ubuntu

apt-get install docker-compose

Add Gitea User (optional)

adduser --system --shell /bin/bash --gecos 'Git Version Control' --group --disabled-password --home /home/git git

Prepare Gitea Folders and Users

gpasswd -a $LOGNAME docker
mkdir -p ~/docker/gitea/{data,config}
chown 1000:1000 ~/docker/

Create ~/gitea/docker-compose.yml

```bash cat << "EOF" > ~/docker/docker-compose.yml # Copyright Broadcom, Inc. All Rights Reserved. # SPDX-License-Identifier: APACHE-2.0

services: postgresql: image: docker.io/bitnami/postgresql:latest volumes: - 'postgresql_data:/bitnami/postgresql' environment: - POSTGRESQL_DATABASE=bitnami_gitea - POSTGRESQL_USERNAME=bn_gitea - POSTGRESQL_PASSWORD=bitnami1 # ALLOW_EMPTY_PASSWORD is recommended only for development. - ALLOW_EMPTY_PASSWORD=yes gitea: image: docker.io/bitnami/gitea:1 volumes: - 'gitea_data:/bitnami/gitea' environment: - GITEA_DATABASE_HOST=postgresql - GITEA_DATABASE_NAME=bitnami_gitea - GITEA_DATABASE_USERNAME=bn_gitea - GITEA_DATABASE_PASSWORD=bitnami1 ports: - '3000:3000' - '2222:2222' volumes: postgresql_data: driver: local gitea_data: driver: local ```

Start Docker Composer Daemon for Gitea

cd ~/docker
docker-compose up -d

Update to Latest Version: docker-compose.yml

docker-compose pull

Enter Gitea Bash Shell

docker exec -it gitea bash

NGinx

Install Nginx on Ubuntu

apt install -y nginx php-fpm php 
# docker: apt install docker docker-compose

Install Certbot / Letsencrypt

apt install -y certbot python3-certbot-nginx

Request For An Certification

certbot --nginx -d git.nr1.nu -m info@nr1.nu

Configure sites-available for Gitea

cat << "EOF" > /etc/nginx/sites-available/git.nr1.nu
server {

    server_name git.nr1.nu;

    root /var/www/html;

    location / {
        # Proxy all requests to Gitea running on port 3000
        proxy_pass http://localhost:3000;
        
        # Pass on information about the requests to the proxied service using headers
        proxy_set_header HOST $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Create Symlink for Nginx

sudo ln -s /etc/nginx/sites-available/gitea.nr1.nu /etc/nginx/sites-enabled/gitea.nr1.nu

Check Nginx Syntax and Start Gitea

nginx -t

Start / Restart gitea

/etc/init.d/nginx restart