• Stars
    star
    202
  • Rank 186,812 (Top 4 %)
  • Language
    Rust
  • License
    GNU Affero Genera...
  • Created over 3 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Update notifications for nextcloud clients

Client Push

Update notifications for nextcloud clients

About

This app attempts to solve the issue where Nextcloud clients have to periodically check the server if any files have been changed. In order to keep sync snappy, clients wants to check for updates often, which increases the load on the server.

With many clients all checking for updates a large portion of the server load can consist of just these update checks.

By providing a way for the server to send update notifications to the clients, the need for the clients to make these checks can be greatly reduced.

Update notifications are provided on a "best effort" basis, updates might happen without a notification being sent and a notification can be sent even if no update has actually happened. Clients are advised to still perform periodic checks for updates on their own, although these can be run on a much lower frequency.

Requirements

This app requires a redis server to be setup and for nextcloud to be configured to use the redis server.

Quick setup

The app comes with a setup wizard that should guide you through the setup process for most setups.

  • Install the "Client Push" (notify_push) app from the appstore
  • Run occ notify_push:setup and follow the provided instructions, If the setup wizard fails you can find manual instructions below.

Manual setup

The setup required consists of three steps

  • Install the notify_push app from the appstore
  • Setting up the push server
  • Configuring the reverse proxy
  • Configuring the nextcloud app

Push server

The push server should be setup to run as a background daemon, the recommended way is by setting it up as a system service in the init system. If you're not using systemd then any init or process management system that runs the push server binary with the described environment variables will work.

systemd

For systemd based setups, you can create a systemd service by creating a file named /etc/systemd/system/notify_push.service with the following content.

[Unit]
Description = Push daemon for Nextcloud clients
Documentation=https://github.com/nextcloud/notify_push

[Service]
Environment = PORT=7867 # Change if you already have something running on this port
ExecStart = /path/to/push/binary/notify_push /path/to/nextcloud/config/config.php
User=www-data

[Install]
WantedBy = multi-user.target
Snap configuration (click to expand)

If you have installed Nextcloud via Snap, you need to use the following file instead and replace CHANGEME in DATABASE_URL with the value of dbpassword from /var/snap/nextcloud/current/nextcloud/config/config.php

[Unit]
Description = Push daemon for Nextcloud clients

[Service]
Environment=PORT=7867 # Change if you already have something running on this port
Environment=DATABASE_URL=mysql://nextcloud:CHANGEME@localhost/nextcloud?socket=/tmp/snap-private-tmp/snap.nextcloud/tmp/sockets/mysql.sock
Environment=REDIS_URL=redis+unix:///tmp/snap-private-tmp/snap.nextcloud/tmp/sockets/redis.sock
ExecStart=/var/snap/nextcloud/current/nextcloud/extra-apps/notify_push/bin/x86_64/notify_push /var/snap/nextcloud/current/nextcloud/config/config.php
User=root

[Install]
WantedBy = multi-user.target

OpenRC

For OpenRC based setups, you can create an OpenRC service by creating a file named /etc/init.d/notify_push with the following content.

#!/sbin/openrc-run

description="Push daemon for Nextcloud clients"

output_log=${output_log:-/var/log/$RC_SVCNAME.log}
pidfile=${pidfile:-/run/$RC_SVCNAME.pid}

command=${command:-/path/to/push/binary/notify_push}
command_user=${command_user:-www-data:www-data}
command_args="--port 7867 /path/to/nextcloud/config/config.php"
command_background=true

depend() {
        need net redis
        use nginx php-fpm8 mariadb postgresql
}

start_pre() {
        checkpath --file --owner $command_user $output_log
}

Adjust the paths, ports and user as needed.

Configuration

The push server can be configured either by loading the config from the nextcloud config.php or by setting all options through environment variables.

Re-using the configuration from nextcloud is the recommended way, as it ensures that the configuration remains in sync.

If using the config.php isn't possible, you can configure the push server by setting the following environment variables:

  • DATABASE_URL connection url for the Nextcloud database, e.g. postgres://user:password@db_host/db_name
  • DATABASE_PREFIX database prefix configured in Nextcloud, e.g. oc_
  • REDIS_URL connection url for redis, e.g. redis://redis_host
  • NEXTCLOUD_URL url for the nextcloud instance, e.g. https://cloud.example.com

Or you can specify the options as command line arguments, see notify_push --help for information about the command line arguments.

If a config option is set in multiple sources, the values from the command line argument overwrite values from the environment which in turns overwrites the values from the config.php.

The port the server listens to can only be configured through the environment variable PORT, or --port argument and defaults to 7867. Alternatively you can configure the server to listen on a unix socket by setting the SOCKET_PATH environment variable or --socket-path argument.

Note that Nextcloud load all files matching *.config.php in the config directory in additional to the main config file. You can enable this same behavior by passing the --glob-config option.

TLS Configuration

The push server can be configured to serve over TLS. This is mostly intended for securing the traffic between the push server and the reverse proxy if they are running on different hosts, running without a reverse proxy (or load balancer) is not recommended.

TLS can be enabled by setting the --tls-cert and --tls-key arguments (or the TLS_CERT and TLS_KEY environment variables).

Starting the service

Once the systemd service file is set up with the correct configuration you can start it using

  • systemd: sudo systemctl start notify_push
  • OpenRc: sudo rc-service notify_push start

and enable it to automatically start on boot using

  • systemd: sudo systemctl enable notify_push
  • OpenRc: sudo rc-update add notify_push

Every time this app receives an update you should restart the systemd service using

  • systemd: sudo systemctl restart notify_push
  • OpenRc: sudo rc-service notify_push restart
Alternatively, you can do this automatically via systemctl by creating the following systemd service and path (click to expand)

First create a oneshot service to trigger the daemon restart

/etc/systemd/system/notify_push-watcher.service

[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
Requires=notify_push.service
After=notify_push.service
StartLimitIntervalSec=10
StartLimitBurst=5

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart notify_push.service

[Install]
WantedBy=multi-user.target

Then create a path job to trigger the restart whenever the push binary is changed

/etc/systemd/system/notify_push-watcher.path

[Unit]
Description=Restart Push daemon for Nextcloud clients when it receives updates
Documentation=https://github.com/nextcloud/notify_push
PartOf=notify_push-watcher.service

[Path]
PathModified=/path/to/push/binary/notify_push
Unit=notify_push-watcher.service

[Install]
WantedBy=multi-user.target

Adjusting the path as needed.

Finally, enable it with

sudo systemctl enable notify_push-watcher.path

Reverse proxy

It is strongly recommended to set up the push service behind a reverse proxy, this both removes the need to open a new port to the internet and handles the TLS encryption of the connection to prevent sending credentials in plain text.

You can probably use the same webserver that you're already using for your nextcloud

Nginx

If you're using nginx, add the following location block to the existing server block of the nextcloud server.

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;
}

Note that both trailing slashes are required.

Once the nginx configuration is edit you can reload nginx using.

sudo nginx -s reload

Apache

To use apache as a reverse proxy you first need to enable the proxy modules using

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo a2enmod proxy_wstunnel

Then add the following lines to the <VirtualHost> block used for the Nextcloud server.

ProxyPass /push/ws ws://127.0.0.1:7867/ws
ProxyPass /push/ http://127.0.0.1:7867/
ProxyPassReverse /push/ http://127.0.0.1:7867/

Afterwards you can restart apache using

sudo systemctl restart apache2

Caddy v2

route /push/* {
    uri strip_prefix /push
    reverse_proxy http://127.0.0.1:7867
}

Nextcloud app

Once the push server is configured and the reverse proxy setup, you can enable the notify_push app and tell it where the push server is listening.

  • enable the app occ app:enable notify_push
  • set the url of the push server occ notify_push:setup https://cloud.example.com/push

The app will automatically run some tests to verify that the push server is configured correctly.

Logging

By default, the push server only logs warnings, you can temporarily change the log level with an occ command

occ notify_push:log <level>

Where level is error, warn, info, debug or trace, or restore the log level to the previous value using

occ notify_push:log --restore

Alternatively you can set the log level of the push server in the LOG environment variable.

Metrics

The push server can expose some basic metrics about the number of connected clients and the traffic flowing through the server by setting the METRICS_PORT environment variable.

Once set the metrics are available in a prometheus compatible format at /metrics on the configured port.

Self-signed certificates

If your nextcloud is using a self-signed certificate then you either need to set the NEXTCLOUD_URL to a non-https, local url, or disable certificate verification by setting ALLOW_SELF_SIGNED=true.

Troubleshooting

When running into issues you should always first ensure that you're on the latest release, as your issue might either already be fixed or additional diagnostics might have been added.

"push server is not a trusted proxy"

  • Ensure you haven't added a duplicate trusted_proxies list to your config.php.

  • If you're modified your forwarded_for_headers config, ensure that HTTP_X_FORWARDED_FOR is included.

  • If your nextcloud hostname resolves do a dynamic ip you can try setting the NEXTCLOUD_URL to the internal ip of the server.

    Alternatively, editing the /etc/hosts file to point your nextcloud domain to the internal ip can work in some setups.

  • If you're running your setup in docker and your containers are linked, you should be able to use the name of the nextcloud container as hostname in the NEXTCLOUD_URL

Developing

For information about how to use the push server in your own app or client, see DEVELOPING.md

Test client

For development and testing purposes a test client is provided which can be downloaded from the current release page.
(Click on test_client to download the binary.)
Please note: the Test client is only build for x86_64 Linux currently.

test_client https://cloud.example.com username password

Note that this does not support two-factor authentication of non-default login flows, you can use an app-password in those cases.

More Repositories

1

server

☁️ Nextcloud server, a safe home for all your data
PHP
23,691
star
2

docker

⛴ Docker image of Nextcloud
Shell
5,429
star
3

all-in-one

📦 The official Nextcloud installation method. Provides easy deployment and maintenance with most features included in this one Nextcloud instance.
PHP
3,965
star
4

android

📱 Nextcloud Android app
Java
3,848
star
5

desktop

💻 Desktop sync client for Nextcloud
C++
2,770
star
6

nextcloudpi

📦 Build code for NextcloudPi: Raspberry Pi, Odroid, Rock64, curl installer...
Shell
2,380
star
7

ios

📱 Nextcloud iOS App
Swift
1,800
star
8

spreed

🗨️ Nextcloud Talk – chat, video & audio calls for Nextcloud
JavaScript
1,441
star
9

vm

💻☁📦 The Nextcloud VM (virtual machine appliance), Home/SME Server and scripts for RPi (4). Community developed and maintained.
Shell
1,252
star
10

deck

🗂 Kanban-style project & personal management tool for Nextcloud, similar to Trello
JavaScript
1,136
star
11

bookmarks

🔖 Bookmark app for Nextcloud
JavaScript
956
star
12

notes-android

✎ Android client for Nextcloud Notes app.
Java
896
star
13

calendar

📆 Calendar app for Nextcloud
JavaScript
887
star
14

mail

💌 Mail app for Nextcloud
JavaScript
788
star
15

news

📰 RSS/Atom feed reader
PHP
786
star
16

passman

🔐 Open source password manager with Nextcloud integration
JavaScript
769
star
17

news-android

📱🗞️ Android client for the Nextcloud news/feed reader app
Java
663
star
18

notes

✎ Distraction-free notes and writing
JavaScript
580
star
19

contacts

📇 Contacts app for Nextcloud
JavaScript
541
star
20

tasks

✅ Tasks app for Nextcloud
JavaScript
536
star
21

text

📑 Collaborative document editing using Markdown
JavaScript
500
star
22

cookbook

🍲 A library for all your recipes
HTML
492
star
23

photos

📸 Your memories under your control
JavaScript
481
star
24

maps

🌍🌏🌎 The whole world fits inside your cloud!
JavaScript
474
star
25

recognize

👁 👂 Smart media tagging for Nextcloud: recognizes faces, objects, landscapes, music genres
PHP
470
star
26

social

🎉 Social can be used for work, or to connect to the fediverse!
PHP
464
star
27

documentation

📘 Nextcloud documentation
JavaScript
464
star
28

talk-android

📱😀 Video & audio calls through Nextcloud on Android
Kotlin
461
star
29

previewgenerator

Nextcloud app to do preview generation in the background.
PHP
440
star
30

richdocuments

📑 Collabora Online for Nextcloud
JavaScript
336
star
31

forms

📝 Simple form & survey app for Nextcloud
JavaScript
301
star
32

twofactor_totp

🔑 Second factor TOTP (RFC 6238) provider for Nextcloud
JavaScript
265
star
33

helm

A community maintained helm chart for deploying Nextcloud on Kubernetes.
Smarty
263
star
34

groupfolders

📁👩‍👩‍👧‍👦 Admin-configured folders shared by everyone in a group. https://github.com/nextcloud-releases/groupfolders
PHP
262
star
35

appstore

🏪 App Store for Nextcloud
Python
262
star
36

end_to_end_encryption

🔐 Server API to support End-to-End Encryption
PHP
253
star
37

polls

🗳️ Polls app for Nextcloud
JavaScript
249
star
38

providers

community-maintained list of Nextcloud providers
213
star
39

nextcloud.com

🌏 Our website
PHP
207
star
40

backup

Backup now. Restore later.
PHP
202
star
41

nextcloud-vue

🍱 Vue.js components for Nextcloud app development ✌ https://npmjs.org/@nextcloud/vue
Vue
198
star
42

client_theming

💻 Nextcloud themed desktop client - Moved over to https://github.com/nextcloud/desktop
Shell
197
star
43

fulltextsearch

🔍 Core of the full-text search framework for Nextcloud
PHP
197
star
44

ocsms

📱 Nextcloud/ownCloud PhoneSync server application
JavaScript
190
star
45

circles

👪 Create groups with other users on a Nextcloud instance and share with them
PHP
139
star
46

registration

User registration app for Nextcloud
JavaScript
134
star
47

ansible-collection-nextcloud-admin

The ansible galaxy for your nextcloud administrative needs.
Jinja
130
star
48

cms_pico

🗃 Integrate Pico CMS and let your users manage their own websites
PHP
127
star
49

talk-ios

📱😀 Video & audio calls through Nextcloud on iOS
Objective-C
123
star
50

documentserver_community

Document server for onlyoffice
PHP
122
star
51

tables

🍱 Nextcloud tables app
JavaScript
114
star
52

twofactor_u2f

🔑 U2F second factor provider for Nextcloud
JavaScript
113
star
53

passman-webextension

Webextension for the Passman Nextcloud app. Also offers browser extension & Android app.
JavaScript
111
star
54

talk-desktop

💬💻 Nextcloud Talk Desktop Client Preview
JavaScript
110
star
55

gallery

DEPRECATED Gallery app was replaced by Photos
JavaScript
110
star
56

twofactor_gateway

🔑 Second factor provider using an external messaging gateway (SMS, Telegram, Signal)
PHP
109
star
57

activity

⚡ Activity app for Nextcloud
JavaScript
108
star
58

external

🌐 Embed external sites in your Nextcloud
JavaScript
104
star
59

notifications

🔔 Notifications app for Nextcloud
PHP
102
star
60

user_external

👥 External user authentication methods like IMAP, SMB and FTP
PHP
101
star
61

news-updater

📰 Fast, parallel feed updater for the News app; written in Python
Python
100
star
62

neon

A framework for building convergent cross-platform Nextcloud clients using Flutter.
Dart
100
star
63

integration_google

🇬 Google integration into Nextcloud
JavaScript
98
star
64

nextcloud-filelink

✉️ 📤 "Nextcloud for Filelink" is a Thunderbird extension which makes it easy to send large attachments with Thunderbird by uploading them first to a Nextcloud server and by then inserting the link into the body of your email.
JavaScript
96
star
65

user_saml

🔒 App for authenticating Nextcloud users using SAML https://apps.nextcloud.com/apps/user_saml
PHP
93
star
66

files_videoplayer

📼 Old video viewer for Nextcloud
JavaScript
91
star
67

health

Nextcloud health app
JavaScript
89
star
68

passman-android

🔑 Android app for Passman.
C++
89
star
69

android-library

☎️ Nextcloud Android library
Java
85
star
70

serverinfo

📊 A monitoring app which creates a server info dashboard for admins
JavaScript
85
star
71

viewer

🖼 Simple file viewer with slideshow for media
JavaScript
83
star
72

unsplash

📸🔀☁️ Random Nextcloud log in background from Unsplash
JavaScript
82
star
73

files_pdfviewer

📖 A PDF viewer for Nextcloud
JavaScript
81
star
74

suspicious_login

Detect and warn about suspicious IPs logging into Nextcloud
PHP
80
star
75

fulltextsearch_elasticsearch

🔍 Use Elasticsearch to index the content of your Nextcloud
PHP
77
star
76

files_antivirus

👾 Antivirus app for Nextcloud Files
JavaScript
74
star
77

collectives

Collectives is a Nextcloud App for activist and community projects to organize together.
JavaScript
73
star
78

Android-SingleSignOn

Single sign-on for Nextcloud (Android Library Project)
Java
70
star
79

files_texteditor

📄 Text editor for plaintext files
JavaScript
69
star
80

user_oidc

OIDC connect user backend for Nextcloud
PHP
66
star
81

workflow_script

Rule based processing of files through specified external scripts
PHP
65
star
82

user_sql

🔒 App for authenticating Nextcloud users using SQL
PHP
65
star
83

files_rightclick

👉 Right click menu for Nextcloud
JavaScript
64
star
84

ransomware_protection

An app that prevents uploading files that have names that are linked to known ransomware
PHP
62
star
85

windows-universal

📱 Nextcloud Windows Mobile app
C#
58
star
86

dashboard

ARCHIVED, new Dashboard is in the server
PHP
58
star
87

security-advisories

👮 Security advisories of Nextcloud
PHP
55
star
88

integration_whiteboard

✏ A whiteboard for Nextcloud, using Spacedeck
PHP
53
star
89

files_automatedtagging

🔖 An app for Nextcloud that assigns tags to newly uploaded files based on some conditions
JavaScript
53
star
90

logreader

📜 Log reader for Nextcloud
JavaScript
52
star
91

calendar_resource_management

Resources back-end for the Nextcloud CalDAV server
PHP
52
star
92

impersonate

👻 Allow administrators to become a different user
JavaScript
52
star
93

cdav-library

📅 📇 CalDAV and CardDAV client library for JavaScript
JavaScript
51
star
94

integration_openproject

Integration of OpenProject project manager in Nextcloud
PHP
51
star
95

3rdparty

🔋 3rd party libraries that are needed to run Nextcloud
PHP
51
star
96

files_fulltextsearch

🔍 Index the content of your files
PHP
50
star
97

files_accesscontrol

🚫 App to manage access control for files
PHP
49
star
98

integration_github

🐙 GitHub integration into Nextcloud
JavaScript
49
star
99

strengthify

🔒🔍 Combine jQuery and zxcvbn to create a password strength meter
JavaScript
49
star
100

bruteforcesettings

🕵 Allow admins to configure the brute force settings
JavaScript
48
star