2026年11月15日星期日

nextclod 客户端推送 notify_push安装

 sudo mkdir -p /opt/notify_push

下载:https://github.com/nextcloud/notify_push/releases/latest 到/opt/notify_push,然后改名notify_push

sudo install -m 755 notify_push /opt/notify_push/notify_push

检查是否正常:

/opt/notify_push/notify_push --help

创建:/etc/systemd/system/notify_push.service

[Unit]
Description=Nextcloud Client Push Service
After=network.target nginx.service redis-server.service
[Service]
Environment="NEXTCLOUD_URL=http://127.0.0.1:8311" #和nginx的配置对应
Environment=PORT=7867
ExecStart=/opt/notify_push/notify_push /var/www/nextcloud/config/config.php
Type=notify
User=www-data
Group=www-data
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target


然后:

sudo systemctl daemon-reload

sudo systemctl enable notify_push

sudo systemctl start notify_push

配置 Nginx 反向代理

这是非常关键的一步。

打开 Nextcloud 对应的 Nginx 虚拟主机配置文件:

sudo nano /etc/nginx/sites-enabled/nextcloud

在对应的 server {} 中添加:

listen 192.168.2.11 ssl proxy_protocol; # 需要添加proxy_protocol 以便获取客户端的实际IP地址,记得在xray的客户端添加 "proxyProtocol": 1
listen 127.0.0.1 ssl;
listen 127.0.0.1:8311; #注意,这个配置和notify_push.service的配置对应
set_real_ip_from 192.168.2.1; #配合上面的proxy_protocol
real_ip_header proxy_protocol; #配合上面的proxy_protocol

	location ^~ /push/ {
		proxy_pass http://127.0.0.1:7867/;

		proxy_http_version 1.1;

		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";

		proxy_set_header Host $host;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

		proxy_read_timeout 3600s;
		proxy_send_timeout 3600s;

		proxy_buffering off;
	}
	location /standalone-signaling/ {
		proxy_pass http://127.0.0.1:8080/;
		proxy_http_version 1.1;
		proxy_set_header Upgrade $http_upgrade;
		proxy_set_header Connection "Upgrade";
		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_read_timeout 86400s;
		proxy_send_timeout 86400s;
	}

执行 Nextcloud 推送服务配置

现在回到 Nextcloud,执行:

cd /var/www/nextcloud

sudo -u www-data php occ app:enable notify_push

然后执行:

sudo -u www-data php occ notify_push:setup https://cloud.example.com/push

信任本机:

cd /var/www/nextcloud

sudo -u www-data php occ config:system:set trusted_proxies 0 \
  --value="127.0.0.1"

检查:

sudo -u www-data php occ config:system:get trusted_proxies
sudo -u www-data php occ notify_push:self-test









没有评论:

发表评论

Nextcloud Talk 高性能后端配置

先生成几个密钥,后面会用到: bash openssl rand -hex 32 # TURN_SECRET(coturn 与 signaling 共用) openssl rand -hex 32 # BACKEND_SECRET(signaling 与 Nextclo...