Gitea server on OpenBSD

This guide will help you set up a Gitea server on OpenBSD 6.3 with PostgreSQL and using the built in OpenBSD httpd server. The following guide is still applicable to OpenBSD 6.4 without modification.

Gitea is a a painless self-hosted Git service. Gitea is a community managed fork of Gogs, lightweight code hosting solution written in Go and published under the MIT license. It is also made with the intention of being easy to install, making it a great solution overall for a small-medium scale Git service.

  1. Install the necessary packages

    pkg_add -z go gitea postgresql-server postgresql-client
  2. Edit /etc/rc.conf.local

    pkg_scripts=postgresql gitdaemon gitea
  3. Start the services

    rcctl gitdaemon start
    rcctl gitea start
  4. Create the database

    mkdir /var/postgresql/data
    initdb -D /var/postgresql/data -U postgres -E UTF8 -A md5 -W
    pg_ctl -D /var/postgresql/data start
    createuser -U postgres --pwprompt --no-superuser --createdb --no-createrole gitea
    createdb -U gitea gitea
  5. Create the self-signed keys. Replace the IP with the IP address of your own server. The purpose of this is so that relayd automatically detects and begins using them.

    openssl genrsa -out /etc/ssl/private/
    openssl req -new -x509 -key /etc/ssl/private/ -out /etc/ssl/ -days 3365
  6. Configure /etc/relayd.conf. Note replace host value URL with your own as well as the listen on IP address.

    table <gitea> { }
    http protocol "httpproxy" {
    pass request quick header "Host" value "" \
        forward to <gitea>
    relay "proxy" {
        listen on port 443 tls 
        protocol "httpproxy"
        forward to <gitea> port 3000 
  7. Start httpd

    rcctl start relayd
  8. Make required directory for Gitea

    mkdir -p /usr/local/share/gitea/data/lfs
  9. Access Gitea at the below URL and go through the installation

    https://ip address>
  10. After the installation edit /etc/gitea/conf/app.ini as following

    PROTOCOL               = http
    DOMAIN                 =
    ROOT_URL               =
    HTTP_ADDR              =
    HTTP_PORT              = 3000
    LOCAL_ROOT_URL         =
    SSH_DOMAIN             =
  11. Restart Gitea due to the app.ini changes

    rcctl restart gitea

You should now be able to access your Gita instance at