Brandon Rozek

Photo of Brandon Rozek

PhD Student @ RPI studying Automated Reasoning in AI and Linux Enthusiast.

Mirroring with Gitea

Published on

Updated on

2 minute reading time

Warning: This post has not been modified for over 2 years. For technical posts, make sure that it is still relevant.

Sites like Github, Gitlab, and BitBucket have nice UIs that make looking at commit diffs and issue tracking easier. However, this requires an internet connection. What if we can mirror the content from these sites locally? Gitea comes to the rescue!


Download gitea and make it executable.

wget -O gitea https://dl.gitea.io/gitea/1.13.0/gitea-1.13.0-linux-amd64
chmod +x gitea

Create the stow directory

sudo mkdir /usr/local/stow/gitea-1.13.0

Start by moving the executable to this directory

sudo mkdir /usr/local/stow/gitea-1.13.0/bin
sudo mv gitea-1.13.0-linux-amd64 \

Add a git user that gitea will use.

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

Create directories gitea expects.

sudo mkdir -p /usr/local/stow/gitea-1.13.0/var/lib/gitea/{custom,data,log}
sudo chown -R git:git /usr/local/stow/gitea-1.13.0/var/lib/gitea
sudo chmod -R 750 /usr/local/stow/gitea-1.13.0/var/lib/gitea

sudo mkdir -p /usr/local/stow/gitea-1.13.0/etc/gitea
sudo chown root:git /usr/local/stow/gitea-1.13.0/etc/gitea
sudo chmod 770 /usr/local/stow/gitea-1.13.0/etc/gitea

Stow gitea

cd /usr/local/stow
sudo stow gitea-1.13.0

Systemd Service

Edit /usr/lib/systemd/system/gitea.service.

Description=Gitea (Git with a cup of tea)

ExecStart=/usr/local/bin/gitea web --config /usr/local/etc/gitea/app.ini
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/usr/local/var/lib/gitea


Start and enable gitea.

sudo systemctl start gitea
sudo systemctl enable gitea

Gitea Setup

Go to http://localhost:3000/install

Check “Enable Local Mode” For security, check “Disable Self-Registration” and “Require Sign-In to View Pages” Setup the “Administrator Account Settings”

Nginx Setup

Edit /etc/nginx/sites-available/gitea.conf

location /gitea/ {
    proxy_pass http://localhost:3000/;
    proxy_http_version 1.1;
    proxy_set_header X-Real-IP  $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr; 
    proxy_set_header Host $host;

Enable the site

sudo ln -s \
        /etc/nginx/sites-available/gitea.conf \
sudo systemctl restart nginx

Apache HTTPD Setup

Edit /etc/httpd/conf.d/gitea.conf

<Location /gitea>
    ProxyPass http://localhost:3000 retry=0 timeout=5
    ProxyPassReverse http://localhost:3000
    ProxyPreserveHost On

    Order allow,deny
    Allow from all

Restart httpd

sudo systemctl restart httpd


To mirror a repo, first click on the plus sign and select “New Migration”, then make sure to check the “This repository will be a mirror”.

Reply via Email Buy me a Coffee
Was this useful? Feel free to share: Hacker News Reddit Twitter

Published a response to this? :