Skip to content

Commit 408bfa6

Browse files
committed
document redis tls
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 44e4046 commit 408bfa6

1 file changed

Lines changed: 93 additions & 51 deletions

File tree

README.md

Lines changed: 93 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- SPDX-FileCopyrightText: 2020 Nextcloud GmbH and Nextcloud contributors
33
- SPDX-License-Identifier: AGPL-3.0-or-later
44
-->
5+
56
# Client Push
67

78
[![REUSE status](https://api.reuse.software/badge/github.com/nextcloud/notify_push)](https://api.reuse.software/info/github.com/nextcloud/notify_push)
@@ -45,43 +46,49 @@ The setup required consists of three steps
4546
- Configuring the nextcloud app
4647

4748
> __For Nextcloud Snap users:__ \
48-
The snap team made a wiki page how to install Client Push in Nextcloud snap. See [their Wiki page](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Configure-HPB-client-push-for-Nextcloud-snap)!
49+
> The snap team made a wiki page how to install Client Push in Nextcloud snap.
50+
>
51+
See [their Wiki page](https://github.com/nextcloud-snap/nextcloud-snap/wiki/Configure-HPB-client-push-for-Nextcloud-snap)!
4952

5053
### Push server
5154

52-
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.
53-
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.
55+
The push server should be setup to run as a background daemon, the recommended way is by setting it up as a system
56+
service in the init system.
57+
If you're not using systemd then any init or process management system that runs the push server binary with the
58+
described environment variables will work.
5459

5560
#### systemd
5661

57-
58-
For systemd based setups, you can create a systemd service by creating a file named `/etc/systemd/system/notify_push.service` with the following
62+
For systemd based setups, you can create a systemd service by creating a file named
63+
`/etc/systemd/system/notify_push.service` with the following
5964
content.
6065

6166
```ini
6267
[Unit]
6368
Description = Push daemon for Nextcloud clients
64-
Documentation=https://github.com/nextcloud/notify_push
69+
Documentation = https://github.com/nextcloud/notify_push
6570

6671
[Service]
6772
# Change if you already have something running on this port
6873
Environment = PORT=7867
6974
ExecStart = /path/to/push/binary/notify_push /path/to/nextcloud/config/config.php
7075
# requires the push server to have been build with the systemd feature (enabled by default)
71-
Type=notify
72-
User=www-data
73-
Restart=always
74-
RestartSec=60
76+
Type = notify
77+
User = www-data
78+
Restart = always
79+
RestartSec = 60
7580

7681
[Install]
7782
WantedBy = multi-user.target
7883
```
7984

80-
If the push server has not been compiled with the optional systemd feature (enabled by default) the `Type=notify` line has to be removed.
85+
If the push server has not been compiled with the optional systemd feature (enabled by default) the `Type=notify` line
86+
has to be removed.
8187

8288
#### OpenRC
8389

84-
For OpenRC based setups, you can create an OpenRC service by creating a file named `/etc/init.d/notify_push` with the following content.
90+
For OpenRC based setups, you can create an OpenRC service by creating a file named `/etc/init.d/notify_push` with the
91+
following content.
8592

8693
```sh
8794
#!/sbin/openrc-run
@@ -108,37 +115,65 @@ start_pre() {
108115

109116
Adjust the paths, ports and user as needed.
110117

111-
112118
#### Configuration
113119

114-
The push server can be configured either by loading the config from the nextcloud `config.php` or by setting all options through environment variables.
120+
The push server can be configured either by loading the config from the nextcloud `config.php` or by setting all options
121+
through environment variables.
115122

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

118-
If using the `config.php` isn't possible, you can configure the push server by setting the following environment variables:
125+
If using the `config.php` isn't possible, you can configure the push server by setting the following environment
126+
variables:
119127

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

125-
Or you can specify the options as command line arguments, see `notify_push --help` for information about the command line arguments.
133+
Or you can specify the options as command line arguments, see `notify_push --help` for information about the command
134+
line arguments.
126135

127-
If a config option is set in multiple sources, the values from the command line argument overwrite values from the environment
136+
If a config option is set in multiple sources, the values from the command line argument overwrite values from the
137+
environment
128138
which in turns overwrites the values from the `config.php`.
129139

130-
The port the server listens to can only be configured through the environment variable `PORT`, or `--port` argument and defaults to 7867.
131-
Alternatively you can configure the server to listen on a unix socket by setting the `SOCKET_PATH` environment variable or `--socket-path` argument.
140+
The port the server listens to can only be configured through the environment variable `PORT`, or `--port` argument and
141+
defaults to 7867.
142+
Alternatively you can configure the server to listen on a unix socket by setting the `SOCKET_PATH` environment variable
143+
or `--socket-path` argument.
132144

133-
Note that Nextcloud load all files matching `*.config.php` in the config directory in additional to the main config file.
145+
Note that Nextcloud loads all files matching `*.config.php` in the config directory in additional to the main config
146+
file.
134147
You can enable this same behavior by passing the `--glob-config` option.
135148

149+
#####
150+
151+
<details>
152+
<summary>Connecting to redis over TLS
153+
</summary>
154+
155+
You can connect to redis over TLS by specifying `rediss://` as the redis url.
156+
157+
The client certificate and key can be set with the `--redis-tls-cert` and `--redis-tls-key` arguments (or the
158+
`REDIS_TLS_CERT` and `REDIS_TLS_KEY` environment variables).
159+
The certificate authority for validating the server certificate can be set with the `--redis-tls-ca` argument (or the
160+
`REDIS_TLS_CA` environment variable).
161+
162+
Additionally, you can disable validating the hostname of the server certificate with
163+
`--redis-tls-dont-validate-hostname` or disable all certificate validation altogether with `--redis-tls-insecure` (or
164+
the `REDIS_TLS_DONT_VALIDATE_HOSTNAME` and `REDIS_TLS_INSECURE` environment variables respectively).
165+
166+
</details>
167+
136168
#### TLS Configuration
137169

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

141-
TLS can be enabled by setting the `--tls-cert` and `--tls-key` arguments (or the `TLS_CERT` and `TLS_KEY` environment variables).
175+
TLS can be enabled by setting the `--tls-cert` and `--tls-key` arguments (or the `TLS_CERT` and `TLS_KEY` environment
176+
variables).
142177

143178
#### Starting the service
144179

@@ -150,58 +185,58 @@ Once the systemd service file is set up with the correct configuration you can s
150185
and enable it to automatically start on boot using
151186

152187
- systemd: `sudo systemctl enable notify_push`
153-
- OpenRc: `sudo rc-update add notify_push`
154-
188+
- OpenRc: `sudo rc-update add notify_push`
155189

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

158192
- systemd: `sudo systemctl restart notify_push`
159193
- OpenRc: `sudo rc-service notify_push restart`
160194

161-
162195
<details>
163196
<summary>Alternatively, you can do this automatically via systemctl by creating the following systemd service and path (click to expand)</summary>
164197

165198
First create a oneshot service to trigger the daemon restart
166199

167200
`/etc/systemd/system/notify_push-watcher.service`
201+
168202
```ini
169203
[Unit]
170-
Description=Restart Push daemon for Nextcloud clients when it receives updates
171-
Documentation=https://github.com/nextcloud/notify_push
172-
Requires=notify_push.service
173-
After=notify_push.service
174-
StartLimitIntervalSec=10
175-
StartLimitBurst=5
204+
Description = Restart Push daemon for Nextcloud clients when it receives updates
205+
Documentation = https://github.com/nextcloud/notify_push
206+
Requires = notify_push.service
207+
After = notify_push.service
208+
StartLimitIntervalSec = 10
209+
StartLimitBurst = 5
176210

177211
[Service]
178-
Type=oneshot
179-
ExecStart=/usr/bin/systemctl restart notify_push.service
212+
Type = oneshot
213+
ExecStart = /usr/bin/systemctl restart notify_push.service
180214

181215
[Install]
182-
WantedBy=multi-user.target
216+
WantedBy = multi-user.target
183217
```
184218

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

187221
`/etc/systemd/system/notify_push-watcher.path`
222+
188223
```ini
189224
[Unit]
190-
Description=Restart Push daemon for Nextcloud clients when it receives updates
191-
Documentation=https://github.com/nextcloud/notify_push
192-
PartOf=notify_push-watcher.service
225+
Description = Restart Push daemon for Nextcloud clients when it receives updates
226+
Documentation = https://github.com/nextcloud/notify_push
227+
PartOf = notify_push-watcher.service
193228

194229
[Path]
195-
PathModified=/path/to/push/binary/notify_push
196-
Unit=notify_push-watcher.service
230+
PathModified = /path/to/push/binary/notify_push
231+
Unit = notify_push-watcher.service
197232

198233
[Install]
199-
WantedBy=multi-user.target
234+
WantedBy = multi-user.target
200235
```
201236

202237
Adjusting the path as needed.
203238

204-
Finally, enable it with
239+
Finally, enable it with
205240

206241
```bash
207242
sudo systemctl enable notify_push-watcher.path
@@ -212,7 +247,8 @@ sudo systemctl enable notify_push-watcher.path
212247
### Reverse proxy
213248

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

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

@@ -299,16 +335,19 @@ Alternatively you can set the log level of the push server in the `LOG` environm
299335

300336
### Metrics
301337

302-
The push server can expose some basic metrics about the number of connected clients and the traffic flowing through the server
338+
The push server can expose some basic metrics about the number of connected clients and the traffic flowing through the
339+
server
303340
by setting the `METRICS_PORT` environment variable.
304341

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

307-
Additionally you can manually check the metrics by running the `occ notify_push:metrics` command, this will function even if you haven't setup `METRICS_PORT`.
344+
Additionally you can manually check the metrics by running the `occ notify_push:metrics` command, this will function
345+
even if you haven't setup `METRICS_PORT`.
308346

309347
### Self-signed certificates
310348

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

314353
## Troubleshooting
@@ -320,11 +359,13 @@ already be fixed or additional diagnostics might have been added.
320359

321360
- Ensure you haven't added a duplicate `trusted_proxies` list to your `config.php`.
322361
- If you're modified your `forwarded_for_headers` config, ensure that `HTTP_X_FORWARDED_FOR` is included.
323-
- If your nextcloud hostname resolves do a dynamic ip you can try setting the `NEXTCLOUD_URL` to the internal ip of the server.
324-
325-
Alternatively, editing the `/etc/hosts` file to point your nextcloud domain to the internal ip can work in some setups.
326-
- 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`
362+
- If your nextcloud hostname resolves do a dynamic ip you can try setting the `NEXTCLOUD_URL` to the internal ip of the
363+
server.
327364

365+
Alternatively, editing the `/etc/hosts` file to point your nextcloud domain to the internal ip can work in some
366+
setups.
367+
- If you're running your setup in docker and your containers are linked, you should be able to use the name of the
368+
nextcloud container as hostname in the `NEXTCLOUD_URL`
328369

329370
## Developing
330371

@@ -340,4 +381,5 @@ the [current release](https://github.com/nextcloud/notify_push/releases/latest)
340381
test_client https://cloud.example.com username password
341382
```
342383

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

0 commit comments

Comments
 (0)