From d2a3698d20ce3158988f2ef6274e3c9fbad75ee5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=B8=D0=BA=D1=82=D0=BE=D1=80?= <78488229+viktor138irk@users.noreply.github.com> Date: Sat, 9 May 2026 21:34:26 +0900 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=BA=D1=83=D0=BC=D0=B5=D0=BD=D1=82=D0=B0=D1=86?= =?UTF-8?q?=D0=B8=D1=8E=20Pulse=20Push=20Gateway?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/PULSE_PUSH_GATEWAY.md | 112 +++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 docs/PULSE_PUSH_GATEWAY.md diff --git a/docs/PULSE_PUSH_GATEWAY.md b/docs/PULSE_PUSH_GATEWAY.md new file mode 100644 index 0000000..70f422d --- /dev/null +++ b/docs/PULSE_PUSH_GATEWAY.md @@ -0,0 +1,112 @@ +# Pulse Push Gateway + +## Архитектура + +```text +Synapse + ↓ +Pulse Push Gateway + ↓ +Firebase FCM + ↓ +Android Pulse +``` + +## Серверы + +- FastPanel reverse proxy: `192.168.0.221` +- Matrix/Core: `192.168.0.141` + +## Gateway + +Gateway запускается на Matrix/Core сервере: + +```text +192.168.0.141:8509 +``` + +## Установка + +```bash +cd /opt/swchat +mkdir -p push-gateway +cd push-gateway +``` + +Скопировать файлы из репозитория: + +```text +push-gateway/main.py +push-gateway/requirements.txt +``` + +Установка зависимостей: + +```bash +python3 -m venv venv +source venv/bin/activate +pip install -r requirements.txt +``` + +## Firebase + +В Firebase Console: + +- Project settings +- Service accounts +- Generate new private key + +Файл сохранить: + +```text +/opt/swchat/push-gateway/firebase-service-account.json +``` + +## Запуск + +```bash +cd /opt/swchat/push-gateway +source venv/bin/activate +uvicorn main:app --host 0.0.0.0 --port 8509 +``` + +## Проверка + +На VPS/FastPanel: + +```bash +curl http://192.168.0.141:8509/health +``` + +Ожидаемый ответ: + +```json +{ + "status": "ok", + "service": "pulse-push-gateway" +} +``` + +## nginx reverse proxy + +На FastPanel/nginx: + +```nginx +location /_matrix/push/v1/notify { + proxy_pass http://192.168.0.141:8509/_matrix/push/v1/notify; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; +} +``` + +## Важно + +- Не открывать 8509 наружу. +- Доступ к 8509 только из локальной сети. +- SSL остаётся на FastPanel. +- Synapse использует публичный endpoint: + +```text +https://matrix.stackworks.ru/_matrix/push/v1/notify +```