Setting up Gitea

Published on December 29, 2020


Install Gitea:

apk add gitea


Create the user and database:

createuser -U postgres --pwprompt gitea
createdb -U postgres --owner=gitea gitea

Start the service:

/etc/init.d/gitea start
rc-update add gitea

Forward the port using SSH:

ssh -L 3000:localhost:3000

Point your browser to http://localhost:3000/ and configure Gitea.

Edit /etc/nginx/sites-available/

server {
	listen 80;
	listen [::]:80;

	# Redirect HTTP traffic to HTTPS.
	return 301 https://$host$request_uri;

server {
	listen 443 ssl;
	listen [::]:443 ssl;
ssl_certificate /etc/letsencrypt/live/ # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/ # managed by Certbot
	index index.html;

	# HTTP Strict Transport Security.
	add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

	location / {
		proxy_pass http://localhost:3000;

	location /.well-known {
		alias /var/www/;

Create a symlink to enable the site:

ln -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/

Reload the Nginx configuration:

/etc/init.d/nginx reload

If you like my work or if my work has been useful to you in any way, then feel free to donate me a cup of coffee. Any donation is much appreciated!