0%

xpnas Inotify搭建

消息通知系统搭建教程

1. 项目介绍

一个简易的开源消息通知系统,支持企业微信,telegram,邮件等

1.1功能支持

  • 通道设置
  • 用户管理
  • 系统状态
  • 代理设置
  • Github登陆
  • 外部日志

1.2 通道支持

  • 企业微信应用消息
  • 电报机器人消息
  • SMTP邮箱消息
  • BARK
  • 钉钉群机器人
  • 飞书群机器人
  • 自定义

2. 搭建方法

2.1 前置条件

  • 一台服务器
  • 域名
  • Cloudflare账户(可选,但推荐)

2.2 基础环境准备

  • 1.安装docker
    1
    2
    3
    4
    5
    6
    7
    8
    # 更新系统并安装 Docker
    sudo apt update
    sudo apt install -y docker.io
    # 设置 Docker 开机启动并启动服务
    sudo systemctl enable docker
    sudo systemctl start docker
    # 查看 Docker 版本确认安装成功
    docker --version
  • 2.用docker安装inotify发布版
    1
    2
    3
    docker run --name=inotify -d -p 8000:80 -v inotify_data:/inotify_data --restart=always xpnas/inotify:latest
    # 查看容器状态
    docker ps

2.3 Nginx 反向代理配置

  • 创建站点配置文件
    1
    sudo nano /etc/nginx/sites-available/inotify
  • 内容如下(示例域名)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    server {
    listen 80;
    server_name fw.example.com;

    location / {
    proxy_pass http://127.0.0.1:8080;
    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;
    }
    }
  • 启用站点
    1
    2
    3
    4
    5
    6
    sudo ln -s /etc/nginx/sites-available/sms-forwarder \
    /etc/nginx/sites-enabled/
    # 测试配置是否正确
    sudo nginx -t
    # 重载 Nginx 配置
    sudo systemctl reload nginx
  • 用Certbot进行https证书配置
    1
    2
    sudo apt install -y certbot python3-certbot-nginx
    sudo certbot --nginx -d fw.example.com

2.4 github配置

  • 进入Github/Settings/Developer settings/OAuth Apps创建应用
    * 记录Client ID,创建Client secrets
    * Authorization callback URL回调地址填写https://{您的域名}/api/oauth/githubLogin

3. 踩坑记录

3.1 问题现象

  • 旧域名过期
  • 新域名访问后:
    * 页面跳转到域名下其他服务
    * 或直接 502 Bad Gateway
    * GitHub OAuth 登录跳转到旧域名

3.2 502 Bad Gateway 的真实原因

  • 通过排查发现”docker ps -a”发现容器服务没有启动
  • 解决方法:启动服务并设置自动重启
    1
    2
    docker start inotify
    docker update --restart unless-stopped inotify

3.3 GitHub OAuth 跳转旧域名问题

  • 表现为:
    1
    2
    3
    4
    {
    "code": 401,
    "message": "用户被禁用"
    }
  • 或者是跳转到旧域名登陆连接
  • 原因是GitHub OAuth App 回调地址已更新,服务后台仍保留旧 OAuth 配置
  • 解决方法:直接在短信转发服务后台删除旧 GitHub OAuth 配置(该配置并未写死在文件中,而是存储在服务内部数据中。)

4 常用 Docker 排错命令汇总

1
2
3
4
5
docker ps -a                 # 查看所有容器
docker start sms-forwarder # 启动容器
docker logs sms-forwarder # 查看日志
docker exec -it sms-forwarder bash # 进入容器
ss -lntp # 查看端口监听

如果仍有问题,可邮箱联系shumei反馈。
特别感谢!!!xpnas大佬
原创(https://github.com/xpnas/inotify)