|
| 1 | +# Desktop Notifications |
| 2 | + |
| 3 | +With Icinga Notifications, users are able to enable desktop notifications which will inform them about severity |
| 4 | +changes in incidents they are notified about. |
| 5 | + |
| 6 | +> **Note** |
| 7 | +> |
| 8 | +> This feature is currently considered experimental and might not work as expected in all cases. |
| 9 | +> We will continue to improve this feature in the future. Your feedback is highly appreciated. |
| 10 | +
|
| 11 | +## How It Works |
| 12 | + |
| 13 | +A user can enable this feature in their account preferences, in case Icinga Web is being accessed by using a secure |
| 14 | +connection. Once enabled, the web interface will establish a persistent connection to the web server which will push |
| 15 | +notifications to the user's browser. This connection is only established when the user is logged in and has the web |
| 16 | +interface open. This means that if the browser is closed, no notifications will be shown. |
| 17 | + |
| 18 | +For this reason, desktop notifications are not meant to be a primary notification method. This is also the reason |
| 19 | +why they will only show up for incidents a contact is notified about by other means, e.g. email. |
| 20 | + |
| 21 | +In order to link a contact to the currently logged-in user, both the contact's and the user's username must match. |
| 22 | + |
| 23 | +### Supported Browsers |
| 24 | + |
| 25 | +All browsers [supported by Icinga Web](https://icinga.com/docs/icinga-web/latest/doc/02-Installation/#browser-support) |
| 26 | +can be used to receive desktop notifications. Though, most mobile browsers are excluded, due to their aggressive energy |
| 27 | +saving mechanisms. |
| 28 | + |
| 29 | +## Setup |
| 30 | + |
| 31 | +To get this to work, a background daemon needs to be accessible by HTTP through the same location as the web |
| 32 | +interface. Each connection is long-lived as the daemon will push messages by using SSE (Server-Sent-Events) |
| 33 | +to each connected client. |
| 34 | + |
| 35 | +### Configure The Daemon |
| 36 | + |
| 37 | +The daemon is configured in the `config.ini` file located in the module's configuration directory. The default |
| 38 | +location is `/etc/icingaweb2/modules/notifications/config.ini`. |
| 39 | + |
| 40 | +In there, add a new section with the following content: |
| 41 | + |
| 42 | +```ini |
| 43 | +[daemon] |
| 44 | +host = [::] ; The IP address to listen on |
| 45 | +port = 9001 ; The port to listen on |
| 46 | +``` |
| 47 | + |
| 48 | +The values shown above are the default values. You can adjust them to your needs. |
| 49 | + |
| 50 | +### Configure The Webserver |
| 51 | + |
| 52 | +Since connection handling is performed by the background daemon itself, you need to configure your web server to |
| 53 | +proxy requests to the daemon. The following examples show how to configure Apache and Nginx. They're based on the |
| 54 | +default configuration Icinga Web ships with if you've used the `icingacli setup config webserver` command. |
| 55 | + |
| 56 | +Adjust the base URL `/icingaweb2` to your needs and the IP address and the port to what you have configured in the |
| 57 | +daemon's configuration. |
| 58 | + |
| 59 | +**Apache** |
| 60 | + |
| 61 | +``` |
| 62 | +<LocationMatch "^/icingaweb2/notifications/v(?<version>\d+)/subscribe"> |
| 63 | + SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1 |
| 64 | + RequestHeader set X-Icinga-Notifications-Protocol-Version %{MATCH_VERSION}e |
| 65 | + ProxyPass http://127.0.0.1:9001 connectiontimeout=30 timeout=30 flushpackets=on |
| 66 | + ProxyPassReverse http://127.0.0.1:9001 |
| 67 | +</LocationMatch> |
| 68 | +``` |
| 69 | + |
| 70 | +**Nginx** |
| 71 | + |
| 72 | +``` |
| 73 | +location ~ ^/icingaweb2/notifications/v(\d+)/subscribe$ { |
| 74 | + proxy_pass http://127.0.0.1:9001; |
| 75 | + proxy_set_header Connection ""; |
| 76 | + proxy_set_header X-Icinga-Notifications-Protocol-Version $1; |
| 77 | + proxy_http_version 1.1; |
| 78 | + proxy_buffering off; |
| 79 | + proxy_cache off; |
| 80 | + chunked_transfer_encoding off; |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +> **Note** |
| 85 | +> |
| 86 | +> Since these connections are long-lived, the default web server configuration might impose a too small limit on |
| 87 | +> the maximum number of connections. Make sure to adjust this limit to a higher value. If working correctly, the |
| 88 | +> daemon will limit the number of connections per client to 2. |
| 89 | +
|
| 90 | +### Enable The Daemon |
| 91 | + |
| 92 | +The default `systemd` service, shipped with package installations, runs the background daemon. |
| 93 | + |
| 94 | +<!-- {% if not icingaDocs %} --> |
| 95 | + |
| 96 | +> **Note** |
| 97 | +> |
| 98 | +> If you haven't installed this module from packages, you have to configure this as a `systemd` service yourself by just |
| 99 | +> copying the example service definition from `/usr/share/icingaweb2/modules/notifications/config/systemd/icinga-notifications-web.service` |
| 100 | +> to `/etc/systemd/system/icinga-notifications-web.service`. |
| 101 | +<!-- {% endif %} --> |
| 102 | +
|
| 103 | +You can run the following command to enable and start the daemon. |
| 104 | +``` |
| 105 | +systemctl enable --now icinga-notifications-web.service |
| 106 | +``` |
0 commit comments