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

cat << "EOF" > ~/docker/docker-compose.yml
version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.20.5
    container_name: gitea
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - gitea
    volumes:
      - ./gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
      - /home/git/.ssh/:/data/git/.ssh
    ports:
      - "127.0.0.1:4000:3000"
      - "127.0.0.1:4001:22"
EOF

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