Installing a push notifications server Gotify

Ecrit le 01/01/2019

I wanted to install a self-hosted push notification server to have it on hand if I needed it. It can be convenient to have push notifications when needed for personal projects.

I heard of the project Gotify on the Fediverse (I don’t have the toot that goes with it :( ). While installing it, I’ve encountered some minor problems and some incomplete bits in the README or the files in the repository.

How does it works ?

To get things working, you need a client application on your computer / tablet / whaterver you want which will be connected to a WebSocket server and will listen for notifications. The server is in charge of receiving your notifications and sending them to the client via the WebSocket.

A priority system allows some variations between notification types and means to warn you that something happened.

All of this, written in Go.

Installing

Classic stuff; everything’s in the README. To summarize, you have to go to the stable releases page then download the binary which matches your CPU architecture.

Then, you have to decompress it somewhere. I’ve created a new user to keep things separated in the process table and in the permissions.

Configuration

It’s not insurmontable. The content of the configuration file is in the project README, section “Configuration”. The file must be nammed config.yml and be located in the same folder as the executable. While we’re at it, I strongly invite you to change the default login - password admin:admin with something of your choice and stronger. We have more than enough IoT1 that get zombified.

Nginx

Unfortunately, there is not configuration file available and I had to search in the project issues. The issue n°82 has been a great help to craft the config file. I leave mine down there:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''  close;
}

server {
    # I only want to listen on port 443
    listen 443 http2 ssl;
    listen [::]:443 http2 ssl;
    server_name domain.example.com;

    include ssl.conf; # Your configuration with SSL certificates and ciphers here
    
    location / { # Normal requests go here
        proxy_set_header        Host $host;
        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 $scheme;
        proxy_pass      http://server-address-here;
        #proxy_set_header   Upgrade $http_upgrade;
        proxy_connect_timeout   7m;
        proxy_send_timeout  7m;
        proxy_read_timeout  7m;
    }

    # The requests to switch over websocket go here
    # Without this block, the requests for websocket end with a 400 Bad Request
    location /stream {
        proxy_pass      http://server-address-here;
        proxy_set_header    Host $host;
        proxy_set_header    X-Real-IP $remote_addr;
        proxy_set_header    Upgrade $http_upgrade;
        proxy_set_header    Connection "Upgrade";
        proxy_connect_timeout   7m;
        proxy_send_timeout  7m;
        proxy_read_timeout  7m;

    }
}

That’s pretty much it ^w^’

Examples are listed in the README of the project because why not.

Thanks to awesome peeps who helped me correct some awkward sentences



  1. Internet of Things; connected devices. Those devices are victim of attacks on a regular basis because their users didn’t take care of changing the default login and password. They are also called “Internet of Shit” due to their weak security.