Gotify

From Halfface
Jump to navigation Jump to search

install

Download suitable gotify binary. Put in

/usr/local/bin/gotify

Create directories.

/etc/gotify
/var/lib/gotify
chown -R gotify:gotify /var/lib/gotify/data

create user

groupadd -r gotify
useradd -M -d /var/lib/gotify -s /sbin/nologin -r -g gotify gotify

config file

curl -O /etc/gotify/config.yml https://raw.githubusercontent.com/gotify/server/master/config.example.yml

test start

sudo -u gotify /usr/local/bin/gotify

systemd start script

/etc/systemd/system/gotify.service

[Unit]
Description=Gotify Push Notification Server
Documentation=https://gotify.net/docs
After=network-online.target
Wants=network-online.target systemd-networkd-wait-online.service

StartLimitIntervalSec=14400
StartLimitBurst=10 

[Service]
Restart=on-abnormal

User=gotify
Group=gotify 

WorkingDirectory=/var/lib/gotify
ExecStart=/var/lib/gotify

PrivateTmp=true
ProtectSystem=full
ReadWritePaths=/var/lib/gotify/data
ReadWriteDirectories=/var/lib/gotify/data

TimeoutStopSec=5s 

[Install]
WantedBy=multi-user.target

add proxypass to suitable vhost config

# gotify=start
   Redirect 301 "/gotify" "/gotify/"
 
   # The proxy must preserve the host because gotify verifies the host with the origin
   # for WebSocket connections
   ProxyPreserveHost On

   # Proxy web socket requests to /stream
   ProxyPass "/gotify/stream" ws://127.0.0.1:8080/stream retry=0 timeout=5
 
   # Proxy all other requests to /
   ProxyPass "/gotify/" http://127.0.0.1:8080/ retry=0 timeout=5
   #                 ^- !!trailing slash is required!!

   ProxyPassReverse /gotify/ http://127.0.0.1:8080/

# gotify=end

send messages

curl -sk "https://www.halfface.se/gotify/message?token=$TOKEN_ID" -F "title=test title $(date_stockholm)" -F "message=my message. $(date_stockholm)" -F "priority=5"