Setting up a Gotify Server

Introduction

This tutorial will explain how to set up your own Gotify instance.

Environment

Hardware amd64 VPS
OS Debian 10 Buster

Dependencies

  1. Docker
  2. docker-compose
  3. Internet Domain

Step by Step Instructions

1. Add DNS entry to your domain.

A domain of your choice needs to point to the address of your server.

2. Change to root user

sudo -s

3. Installation of additional Dependencies

apt update
apt install -y certbot nginx

4. Create user user and add persistence

useradd --system --create-home --shell /bin/bash --password <your-password-here> gotify
mkdir /home/gotify/data
chown -R gotify:gotify /home/gotify/data

5. Configure NGINX server

Create and open vhost file:

nano /etc/nginx/sites-available/gotify.domain.tld.vhost

Paste the following configuration into the file:

server {
  listen 80;
  server_name gotify.domain.tld;

  location / {
    # We set up the reverse proxy
    proxy_pass         http://127.0.0.1:53852;
    proxy_http_version 1.1;

    # Ensuring it can use websockets
    proxy_set_header   Upgrade $http_upgrade;
    proxy_set_header   Connection "upgrade";
    proxy_set_header   X-Real-IP $remote_addr;
    proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header   X-Forwarded-Proto http;
    proxy_redirect     http:// $scheme://;

    # The proxy must preserve the host because gotify verifies the host with the origin
    # for WebSocket connections
    proxy_set_header   Host $http_host;

    # These sets the timeout so that the websocket can stay alive
    proxy_connect_timeout   7m;
    proxy_send_timeout      7m;
    proxy_read_timeout      7m;
  }

  location ~ /.well-known/acme-challenge/ {
    allow all;
  }
}

Activate vhost file:

ln -s /etc/nginx/sites-available/gotify.domain.tld.vhost /etc/nginx/sites-enabled/gotify.domain.tld.vhost

Restart NGINX:

systemctl restart nginx

6. Create Let's Encrypt certificate for gotify.domain.tld

https://certbot.eff.org/lets-encrypt/debianbuster-nginx

Restart NGINX:

systemctl restart nginx

7. Run server

Create and open docker-compose.yaml:

cd /home/gotify
nano docker-compose.yaml
chmod 600 docker-compose.yaml

Paste the following configuration into the file:

version: '3.3'

services:
  gotify:
    image: gotify/server
    ports:
      - 53852:80
    environment:
      - 'GOTIFY_DEFAULTUSER_NAME=admin'
      - 'GOTIFY_DEFAULTUSER_PASS=your-password-here'
      - 'TZ=Europe/Berlin'
    volumes:
      - '/home/gotify/data:/app/data'

Run server:

docker-compose up -d

8. Getting started

Visit your Gotify server: https://gotify.domain.tld

Log in with the data provided in the docker-compose.yaml.

 

Sources