介绍
Gotify 是用 Go 编写的跨平台开源消息推送服务。
gotify/server
项目的核心,具有 WebUI 和以下功能
- 通过 REST-API 发送消息
- 通过 websocket 连接订阅/接收消息
- 管理用户、客户端和应用程序
gotify/android
- 一个用于订阅 gotify/server 的消息流的 Android 客户端,应用会根据新收到的消息创建推送通知
gotify/cli
- 一个命令行客户端,用于将消息推送到 gotify/server,正常情况不需要此项。
部署方式
Docker部署
拉取镜像
Docker 和 Docker-Compose 安装 请点击参考此处
1 2
| docker pull gotify/server:latest
|
配置 Gotify
此处采用 Docker-Compose
进行部署,环境变量进行配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| version: "3"
services: gotify: image: gotify/server:latest container_name: gotify restart: always network_mode: bridge ports: - 8989:80 environment: - TZ=Asia/Shanghai - GOTIFY_SERVER_PORT=80 - GOTIFY_SERVER_KEEPALIVEPERIODSECONDS=0 - GOTIFY_SERVER_LISTENADDR= - GOTIFY_SERVER_SSL_ENABLED=false - GOTIFY_SERVER_SSL_REDIRECTTOHTTPS=true - GOTIFY_SERVER_SSL_LISTENADDR= - GOTIFY_SERVER_SSL_PORT=443 - GOTIFY_SERVER_SSL_CERTFILE= - GOTIFY_SERVER_SSL_CERTKEY= - GOTIFY_SERVER_SSL_LETSENCRYPT_ENABLED=false - GOTIFY_SERVER_SSL_LETSENCRYPT_ACCEPTTOS=false - GOTIFY_SERVER_SSL_LETSENCRYPT_CACHE=data/certs
- GOTIFY_SERVER_STREAM_PINGPERIODSECONDS=45 - GOTIFY_DATABASE_DIALECT=sqlite3 - GOTIFY_DATABASE_CONNECTION=data/gotify.db - GOTIFY_DEFAULTUSER_NAME=admin - GOTIFY_DEFAULTUSER_PASS=admin - GOTIFY_PASSSTRENGTH=10 - GOTIFY_UPLOADEDIMAGESDIR=data/images - GOTIFY_PLUGINSDIR=data/plugins - GOTIFY_REGISTRATION=false volumes: - "./gotify_data:/app/data"
|
部署
基于官方二进制文件部署
支持的平台
- linux-amd64 (64bit)
- linux-386 (32bit)
- arm-7 (32bit used for Raspberry Pi)
- arm64 (ARMv8)
- windows-386.exe (32bit)
- windows-amd64.exe (64bit)
拉取文件
请自行将 {VERSION}
{PLATFORM}
进行替换,{VERSION}
为版本号,{PLATFORM}
为使用平台,点击查看最新版本
1 2 3
| mkdir gotify cd gotify wget https://github.com/gotify/server/releases/download/v{VERSION}/gotify-{PLATFORM}.zip
|
解压文件
1
| unzip gotify-{PLATFORM}.zip
|
更改权限
1
| chmod +x gotify-{PLATFORM}
|
修改默认配置
在二进制文件同目录下新建config.yml
文件
以下为配置文件内容
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| server: keepaliveperiodseconds: 0 listenaddr: "" port: 80
ssl: enabled: false redirecttohttps: true listenaddr: "" port: 443 certfile: certkey: letsencrypt: enabled: false accepttos: false cache: data/certs hosts:
responseheaders:
cors: alloworigins:
allowmethods:
allowheaders:
stream: pingperiodseconds: 45 allowedorigins:
database: dialect: sqlite3 connection: data/gotify.db
defaultuser: name: admin pass: admin passstrength: 10 uploadedimagesdir: data/images pluginsdir: data/plugins registration: false
|
执行二进制文件
数据库配置(可选)
使用 Postgres 时如果数据库连接启用了 SSL,请去除 sslmode=disable
Dialect | Connection |
---|
sqlite3 | path/to/database.db |
mysql | gotify:secret@tcp(localhost:3306)/gotifydb?charset=utf8&parseTime=True&loc=Local |
postgres | host=localhost port=5432 user=gotify dbname=gotifydb password=secret sslmode=disable |
反向代理(可选)
Nginx
根目录部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| upstream gotify { server 127.0.0.1:1245; }
server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; server_name push.example.com; return 301 https://$host$request_uri;
ssl_certificate 证书文件位置; ssl_certificate_key 证书密钥位置; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
location / { proxy_pass http://gotify; proxy_http_version 1.1; 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://; proxy_set_header Host $http_host;
proxy_connect_timeout 1m; proxy_send_timeout 1m; proxy_read_timeout 1m; } }
|
子目录部署
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| upstream gotify { server 127.0.0.1:1245; }
server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; server_name push.example.com; return 301 https://$host$request_uri;
ssl_certificate 证书文件位置; ssl_certificate_key 证书密钥位置; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
llocation /gotify/ { proxy_pass http://gotify; rewrite ^/gotify(/.*) $1 break; proxy_http_version 1.1; 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://; proxy_set_header Host $http_host;
proxy_connect_timeout 1m; proxy_send_timeout 1m; proxy_read_timeout 1m; } }
|
Caddy 2
根目录部署
1 2 3 4 5
| gotify.example.com { # 设置端口为你在 gotify 中使用的端口 # Websocket 支持、代理头等默认启用 reverse_proxy localhost:1245 }
|
子目录部署
1 2 3 4 5 6 7 8 9
| gotify.example.com { route /gotify/* { uri strip_prefix /gotify # 设置端口为你在 gotify 中使用的端口 # Websocket 支持、代理头等默认启用 reverse_proxy localhost:1245 } redir /gotify /gotify/ }
|