{"slug": "hosting-your-own-git-frontend-service-using-gitea", "title": "Hosting your own git frontend service using Gitea", "summary": "The article provides a step-by-step guide on self-hosting a Git frontend service using Gitea on a Debian server with Nginx. It covers setting up a PostgreSQL database for Gitea, downloading and installing the Gitea executable, and configuring Nginx to make the service accessible at a subdirectory like `your.web.site/git`. The guide also includes instructions for creating a system user, setting file permissions, and enabling the Gitea systemd service.", "body_md": "Hosting your own git frontend service using Gitea\nI recently had interest in starting to work on the implementation of the Concurrent Atomistic-Continuum Method using C++ to take advantage of GPU acceleration. As a first step, I began thinking about where I wanted to host my project. I decided to add hosting my own git server to my list of self-hosted services, including e-mail and matrix chat server. This is a quick guide on how I set up Gitea and configured it on my website. As a note, my web server is a Debian machine using Nginx\nSetting up the database\nI already use PostgreSQL to manage my matrix-synapse database and configured Gitea to use the same.\nFirst, following the Gitea documentation, I set the listen_address\nand password_encryption\nin my postgresql.conf\nat /etc/postgresql/11/main/postgresql.conf\n:\nlisten_addresses = 'localhost, 203.0.113.3'\npassword_encryption = scram-sha-256\nYou should then restart PostgreSQL. Now you can log into the database console:\nsu -c \"psql\" - postgres\nThen create a database user, gitea:\nCREATE ROLE gitea WITH LOGIN PASSWORD '{ReplaceWithStrongPassword}';\nThen you can actually create your gitea database:\nCREATE DATABASE giteadb WITH OWNER gitea TEMPLATE template0 ENCODING UTF8 LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';\nThe last step is adding authentication rules to your pg_hba.conf\nat /etc/postgresql/11/main/pg_hba.conf\n.\nAs a note, the following line should be added near the top of this file as authentication rules are evaluated sequentially.\nAs a result, any generic rule at the top of this file may be used instead of the inserted rule if not inserted first.\nlocal giteadb gitea scram-sha-256\nInstalling and setting up gitea\nSince my server is on debian, I didn’t have access to a gitea package. Instead, I downloaded the executable:\nwget -O gitea https://dl.gitea.com/gitea/1.18.5/gitea-1.18.5-linux-amd64\nchmod +x gitea\nYou should then create a git user account on your server:\nadduser \\\n--system \\\n--shell /bin/bash \\\n--gecos 'Git Version Control' \\\n--group \\\n--disabled-password \\\n--home /home/git \\\ngit\nA few directories need to be created for gitea and file permissions set:\nmkdir -p /var/lib/gitea/{custom,data,log}\nchown -R git:git /var/lib/gitea/\nchmod -R 750 /var/lib/gitea/\nmkdir /etc/gitea\nchown root:git /etc/gitea\nchmod 770 /etc/gitea\nYou can then copy gitea to a directory on your path, i.e.:\ncp gitea /usr/local/bin/gitea\nThe last step for setting up gitea is downloading the example systemd service file and placing that in /etc/systemd/system\n.\nAt this point you should be able to enable and start the service:\nsudo systemctl enable gitea\nsudo systemctl start gitea\nGitea and Nginx configuration\nThere are a few configurations options you need to set for Gitea and Nginx that I’ll outline here.\nFirst as a note, I wanted my git server to be accessible at alexselimov.com/git.\nIt’s possible to set gitea up as a subdomain, i.e. git.some.site\n, but I won’t go into that.\nFirst you want to configure nginx so you can access your Gitea instance.\nYou can also simply go to your.web.site:3000\nto skip the Nginx configuration.\nAdding Gitea at your.web.site/git\nis extremely simple and if you have SSL certificates with certbot, access to your Gitea instance will also occur over HTTPS.\nAll you have to do is add:\nlocation /git/{\nproxy_pass http://localhost:3000/;\nproxy_set_header Host $host;\nproxy_set_header X-Real-IP $remote_addr;\nproxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;\nproxy_set_header X-Forwarded-Proto $scheme;\n}\nin your primary server block for your website.\nNow if you restart Nginx you should be able to navigate to your.web.site/git\n.\nThe first time you access your Gitea instance, it will ask you several configuration questions which then populate the default configuration file for Gitea that you can then adjust.\nAnswer to the best of your knowledge and then we will go over the most important ones in your configuration file.\nGitea configurations are available in the /etc/gitea/app.ini\nfile.\nYou want to double check that your [database]\nsection is correct, especially the NAME\nvariable.\n[database]\nDB_TYPE = postgres\nHOST = 127.0.0.1\nNAME = giteadb\nUSER = gitea\nPASSWD = '{SOME SECURE PASSWORD}'\nIf you want you can set your default branch name in the [repository]\nsection:\n[repository]\nDEFAULT_BRANCH = master\nFinally to make sure your site works properly, you want to go to your [server]\nsection and make sure that [SSH_DOMAIN]\nis set to the domain that you use to ssh into your server.\nFor example, I ssh into alexselimov.com so my app.ini\nhas:\n[server]\nSSH_DOMAIN = alexselimov.com\nYour ROOT_URL\nshould however be set to the url that maps to your Gitea instance, i.e.,\nROOT_URL = https://alexselimov.com/git\nTo finish setting up ssh, you just have to add your public key to your user account in the Gitea under settings->SSH/GPG keys. Then as site admin you have to go to the Site Administration menu and run the “Update the ‘.ssh/authorized_keys’ file with Gitea SSH keys.” option. At this point you should be good to go with Gitea and using ssh to access your repositories. The final option I though was useful was:\n[sevice]\nDISABLE_REGISTRATION = true\nI am making this repo for personal use. Disabling registration still allows people to clone my public repositories, but I want to be sure that I screen potential contributors or other people that can have accounts on my instance.\nConclusion\nI hope these instructions were useful to someone, let me know if I missed a step or got something wrong and I’ll be sure to correct it. Thanks for reading!", "url": "https://wpnews.pro/news/hosting-your-own-git-frontend-service-using-gitea", "canonical_source": "https://www.alexselimov.com/posts/gitea/", "published_at": "2023-02-25 15:19:50+00:00", "updated_at": "2026-05-23 08:38:07.249785+00:00", "lang": "en", "topics": ["open-source", "developer-tools", "cloud-computing"], "entities": ["Gitea", "PostgreSQL", "Nginx", "Debian", "Concurrent Atomistic-Continuum Method", "C++", "GPU", "matrix-synapse"], "alternates": {"html": "https://wpnews.pro/news/hosting-your-own-git-frontend-service-using-gitea", "markdown": "https://wpnews.pro/news/hosting-your-own-git-frontend-service-using-gitea.md", "text": "https://wpnews.pro/news/hosting-your-own-git-frontend-service-using-gitea.txt", "jsonld": "https://wpnews.pro/news/hosting-your-own-git-frontend-service-using-gitea.jsonld"}}