| 1 |
# Configuring the ntfy server |
| 2 |
The ntfy server can be configured in three ways: using a config file (typically at `/etc/ntfy/server.yml`, |
| 3 |
see [server.yml](https://github.com/binwiederhier/ntfy/blob/main/server/server.yml)), via command line arguments |
| 4 |
or using environment variables. |
| 5 |
|
| 6 |
## Quick start |
| 7 |
By default, simply running `ntfy serve` will start the server at port 80. No configuration needed. Batteries included 😀. |
| 8 |
If everything works as it should, you'll see something like this: |
| 9 |
``` |
| 10 |
$ ntfy serve |
| 11 |
2021/11/30 19:59:08 Listening on :80 |
| 12 |
``` |
| 13 |
|
| 14 |
You can immediately start [publishing messages](publish.md), or subscribe via the [Android app](subscribe/phone.md), |
| 15 |
[the web UI](subscribe/web.md), or simply via [curl or your favorite HTTP client](subscribe/api.md). To configure |
| 16 |
the server further, check out the [config options table](#config-options) or simply type `ntfy serve --help` to |
| 17 |
get a list of [command line options](#command-line-options). |
| 18 |
|
| 19 |
## Example config |
| 20 |
!!! info |
| 21 |
Definitely check out the **[server.yml](https://github.com/binwiederhier/ntfy/blob/main/server/server.yml)** file. It contains examples and detailed descriptions of all the settings. |
| 22 |
You may also want to look at how ntfy.sh is configured in the [ntfy-ansible](https://github.com/binwiederhier/ntfy-ansible) repository. |
| 23 |
|
| 24 |
The most basic settings are `base-url` (the external URL of the ntfy server), the HTTP/HTTPS listen address (`listen-http` |
| 25 |
and `listen-https`), and socket path (`listen-unix`). All the other things are additional features. |
| 26 |
|
| 27 |
Here are a few working sample configs using a `/etc/ntfy/server.yml` file: |
| 28 |
|
| 29 |
=== "server.yml (HTTP-only, with cache + attachments)" |
| 30 |
``` yaml |
| 31 |
base-url: "http://ntfy.example.com" |
| 32 |
cache-file: "/var/cache/ntfy/cache.db" |
| 33 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 34 |
``` |
| 35 |
|
| 36 |
=== "server.yml (HTTP+HTTPS, with cache + attachments)" |
| 37 |
``` yaml |
| 38 |
base-url: "http://ntfy.example.com" |
| 39 |
listen-http: ":80" |
| 40 |
listen-https: ":443" |
| 41 |
key-file: "/etc/letsencrypt/live/ntfy.example.com.key" |
| 42 |
cert-file: "/etc/letsencrypt/live/ntfy.example.com.crt" |
| 43 |
cache-file: "/var/cache/ntfy/cache.db" |
| 44 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 45 |
``` |
| 46 |
|
| 47 |
=== "server.yml (behind proxy, with cache + attachments)" |
| 48 |
``` yaml |
| 49 |
base-url: "http://ntfy.example.com" |
| 50 |
listen-http: ":2586" |
| 51 |
cache-file: "/var/cache/ntfy/cache.db" |
| 52 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 53 |
behind-proxy: true |
| 54 |
``` |
| 55 |
|
| 56 |
=== "server.yml (PostgreSQL, behind proxy)" |
| 57 |
``` yaml |
| 58 |
base-url: "https://ntfy.example.com" |
| 59 |
listen-http: ":2586" |
| 60 |
database-url: "postgres://ntfy:[email protected]:5432/ntfy?sslmode=require" |
| 61 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 62 |
behind-proxy: true |
| 63 |
auth-default-access: "deny-all" |
| 64 |
``` |
| 65 |
|
| 66 |
=== "server.yml (ntfy.sh config)" |
| 67 |
``` yaml |
| 68 |
# All the things: Behind a proxy, Firebase, cache, attachments, |
| 69 |
# SMTP publishing & receiving |
| 70 |
|
| 71 |
base-url: "https://ntfy.sh" |
| 72 |
listen-http: "127.0.0.1:2586" |
| 73 |
firebase-key-file: "/etc/ntfy/firebase.json" |
| 74 |
cache-file: "/var/cache/ntfy/cache.db" |
| 75 |
behind-proxy: true |
| 76 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 77 |
smtp-sender-addr: "email-smtp.us-east-2.amazonaws.com:587" |
| 78 |
smtp-sender-user: "AKIDEADBEEFAFFE12345" |
| 79 |
smtp-sender-pass: "Abd13Kf+sfAk2DzifjafldkThisIsNotARealKeyOMG." |
| 80 |
smtp-sender-from: "[email protected]" |
| 81 |
smtp-server-listen: ":25" |
| 82 |
smtp-server-domain: "ntfy.sh" |
| 83 |
smtp-server-addr-prefix: "ntfy-" |
| 84 |
keepalive-interval: "45s" |
| 85 |
``` |
| 86 |
|
| 87 |
Alternatively, you can also use command line arguments or environment variables to configure the server. Here's an example |
| 88 |
using Docker Compose (i.e. `docker-compose.yml`): |
| 89 |
|
| 90 |
=== "Docker Compose (w/ auth, cache, attachments)" |
| 91 |
``` yaml |
| 92 |
services: |
| 93 |
ntfy: |
| 94 |
image: binwiederhier/ntfy |
| 95 |
restart: unless-stopped |
| 96 |
environment: |
| 97 |
NTFY_BASE_URL: http://ntfy.example.com |
| 98 |
NTFY_CACHE_FILE: /var/lib/ntfy/cache.db |
| 99 |
NTFY_AUTH_FILE: /var/lib/ntfy/auth.db |
| 100 |
NTFY_AUTH_DEFAULT_ACCESS: deny-all |
| 101 |
NTFY_AUTH_USERS: 'phil:$$2a$$10$$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin' # Must escape '$' as '$$' |
| 102 |
NTFY_BEHIND_PROXY: true |
| 103 |
NTFY_ATTACHMENT_CACHE_DIR: /var/lib/ntfy/attachments |
| 104 |
NTFY_ENABLE_LOGIN: true |
| 105 |
volumes: |
| 106 |
- ./:/var/lib/ntfy |
| 107 |
ports: |
| 108 |
- 80:80 |
| 109 |
command: serve |
| 110 |
``` |
| 111 |
|
| 112 |
=== "Docker Compose (w/ auth, cache, web push, iOS)" |
| 113 |
``` yaml |
| 114 |
services: |
| 115 |
ntfy: |
| 116 |
image: binwiederhier/ntfy |
| 117 |
restart: unless-stopped |
| 118 |
environment: |
| 119 |
NTFY_BASE_URL: http://ntfy.example.com |
| 120 |
NTFY_CACHE_FILE: /var/lib/ntfy/cache.db |
| 121 |
NTFY_AUTH_FILE: /var/lib/ntfy/auth.db |
| 122 |
NTFY_AUTH_DEFAULT_ACCESS: deny-all |
| 123 |
NTFY_BEHIND_PROXY: true |
| 124 |
NTFY_ATTACHMENT_CACHE_DIR: /var/lib/ntfy/attachments |
| 125 |
NTFY_ENABLE_LOGIN: true |
| 126 |
NTFY_UPSTREAM_BASE_URL: https://ntfy.sh |
| 127 |
NTFY_WEB_PUSH_PUBLIC_KEY: <public_key> |
| 128 |
NTFY_WEB_PUSH_PRIVATE_KEY: <private_key> |
| 129 |
NTFY_WEB_PUSH_FILE: /var/lib/ntfy/webpush.db |
| 130 |
NTFY_WEB_PUSH_EMAIL_ADDRESS: <email> |
| 131 |
volumes: |
| 132 |
- ./:/var/lib/ntfy |
| 133 |
ports: |
| 134 |
- 8093:80 |
| 135 |
command: serve |
| 136 |
``` |
| 137 |
|
| 138 |
## Config generator |
| 139 |
|
| 140 |
This generator helps you configure your self-hosted ntfy instance. It's not fully featured, but it is a good starting point. Please refer to the relevant sections in the doc for more details. |
| 141 |
|
| 142 |
<div style="text-align: center;"> |
| 143 |
<button type="button" id="cg-open-btn" class="cg-open-btn">Open config generator</button> |
| 144 |
</div> |
| 145 |
|
| 146 |
<figure markdown style="padding-left: 50px; padding-right: 50px; cursor: pointer;" onclick="document.getElementById('cg-open-btn').click();"> |
| 147 |
<img src="../../static/img/config-generator.png"/> |
| 148 |
<figcaption>The config generator helps you create a custom config for your self-hosted ntfy instance. Click to open.</figcaption> |
| 149 |
</figure> |
| 150 |
|
| 151 |
<div id="cg-modal" class="cg-modal" style="display:none"> |
| 152 |
<div class="cg-modal-backdrop"></div> |
| 153 |
<div class="cg-modal-dialog"> |
| 154 |
<div class="cg-modal-header"> |
| 155 |
<div class="cg-modal-header-left"> |
| 156 |
<span class="cg-modal-title">Config generator</span><span class="cg-badge-beta">BETA</span> |
| 157 |
<span class="cg-modal-desc">This generator helps you configure your self-hosted ntfy instance. It's not fully featured, but it is a good starting point.</span> |
| 158 |
</div> |
| 159 |
<div class="cg-modal-header-actions"> |
| 160 |
<button type="button" id="cg-reset-btn" class="cg-modal-reset" title="Reset all values">Reset</button> |
| 161 |
<button type="button" id="cg-close-btn" class="cg-modal-close" title="Close">×</button> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
<div class="cg-modal-body"> |
| 165 |
<div class="cg-mobile-toggle"> |
| 166 |
<button class="cg-mobile-toggle-btn active" data-show="left">Edit</button> |
| 167 |
<button class="cg-mobile-toggle-btn" data-show="right">Preview</button> |
| 168 |
</div> |
| 169 |
<div id="cg-left"> |
| 170 |
<div class="cg-nav"> |
| 171 |
<div class="cg-nav-tab active" data-panel="cg-panel-general">General</div> |
| 172 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-database" id="cg-nav-database">Database</div> |
| 173 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-auth" id="cg-nav-auth">Users</div> |
| 174 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-cache" id="cg-nav-cache">Message Cache</div> |
| 175 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-attach" id="cg-nav-attach">Attachments</div> |
| 176 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-webpush" id="cg-nav-webpush">Web Push</div> |
| 177 |
<div class="cg-nav-tab cg-hidden" data-panel="cg-panel-email" id="cg-nav-email">Email</div> |
| 178 |
</div> |
| 179 |
<div class="cg-panels"> |
| 180 |
<div class="cg-panel active" id="cg-panel-general"> |
| 181 |
<div class="cg-field cg-inline-field"> |
| 182 |
<label>What URL will ntfy be reachable on?</label> |
| 183 |
<input type="text" data-key="base-url" placeholder="https://ntfy.example.com"> |
| 184 |
</div> |
| 185 |
<div class="cg-field cg-inline-field"> |
| 186 |
<label>Will ntfy run behind a proxy (e.g. nginx, Caddy)? <a href="/config/#behind-a-proxy-tls-etc" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 187 |
<div class="cg-btn-group"> |
| 188 |
<label><input type="radio" name="cg-proxy" value="no" checked><span>No</span></label> |
| 189 |
<label><input type="radio" name="cg-proxy" value="yes"><span>Yes</span></label> |
| 190 |
</div> |
| 191 |
</div> |
| 192 |
<div class="cg-field cg-inline-field"> |
| 193 |
<label>Will this ntfy server be open or private? <a href="/config/#access-control" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 194 |
<div class="cg-btn-group"> |
| 195 |
<label><input type="radio" name="cg-server-type" value="open" checked><span>Open</span></label> |
| 196 |
<label><input type="radio" name="cg-server-type" value="private"><span>Private</span></label> |
| 197 |
<label><input type="radio" name="cg-server-type" value="custom"><span>Custom</span></label> |
| 198 |
</div> |
| 199 |
</div> |
| 200 |
<div class="cg-field cg-inline-field"> |
| 201 |
<label>Will iOS/iPhone users use this server? <a href="/config/#ios-instant-notifications" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 202 |
<div class="cg-btn-group"> |
| 203 |
<label><input type="radio" name="cg-ios" value="no" checked><span>No</span></label> |
| 204 |
<label><input type="radio" name="cg-ios" value="yes"><span>Yes</span></label> |
| 205 |
</div> |
| 206 |
</div> |
| 207 |
<div class="cg-field cg-inline-field"> |
| 208 |
<label>Do you want to use ntfy as a UnifiedPush distributor? <a href="/config/#example-unifiedpush" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 209 |
<div class="cg-btn-group"> |
| 210 |
<label><input type="radio" name="cg-unifiedpush" value="no" checked><span>No</span></label> |
| 211 |
<label><input type="radio" name="cg-unifiedpush" value="yes"><span>Yes</span></label> |
| 212 |
</div> |
| 213 |
</div> |
| 214 |
<div class="cg-field"> |
| 215 |
<label>Which features do you want to enable?</label> |
| 216 |
<div class="cg-feature-grid"> |
| 217 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-auth"> User management and access control</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-auth">Configure</button></div> |
| 218 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-cache"> Persistent message cache</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-cache">Configure</button></div> |
| 219 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-attach"> Attachments</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-attach">Configure</button></div> |
| 220 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-webpush"> Web push</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-webpush">Configure</button></div> |
| 221 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-smtp-out"> Email notifications</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-email">Configure</button></div> |
| 222 |
<div class="cg-feature-row"><label><input type="checkbox" id="cg-feat-smtp-in"> Email publishing</label><button type="button" class="cg-btn-configure cg-hidden" data-panel="cg-panel-email">Configure</button></div> |
| 223 |
</div> |
| 224 |
</div> |
| 225 |
<div class="cg-field cg-inline-field cg-hidden" id="cg-wizard-db"> |
| 226 |
<label>Which database backend would you like to use? <a href="/config/#database-options" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 227 |
<div class="cg-btn-group"> |
| 228 |
<label><input type="radio" name="cg-db-type" value="sqlite" checked><span>SQLite</span></label> |
| 229 |
<label><input type="radio" name="cg-db-type" value="postgres"><span>PostgreSQL</span></label> |
| 230 |
</div> |
| 231 |
</div> |
| 232 |
</div> |
| 233 |
<div class="cg-panel" id="cg-panel-auth"> |
| 234 |
<div class="cg-panel-desc">Configure user management, access control, and provisioned users/ACLs. See <a href="/config/#access-control" target="_blank">access control</a> for details.</div> |
| 235 |
<div class="cg-field cg-inline-field"> |
| 236 |
<label>Where should the user database be stored?</label> |
| 237 |
<input type="text" data-key="auth-file" placeholder="/var/lib/ntfy/auth.db"> |
| 238 |
</div> |
| 239 |
<div class="cg-field cg-inline-field"> |
| 240 |
<label>What should the default access policy be? <a href="/config/#access-control" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 241 |
<select id="cg-default-access-select"> |
| 242 |
<option value="read-write" selected>Read & Write</option> |
| 243 |
<option value="read-only">Read Only</option> |
| 244 |
<option value="write-only">Write Only</option> |
| 245 |
<option value="deny-all">Deny All</option> |
| 246 |
</select> |
| 247 |
</div> |
| 248 |
<div class="cg-field cg-inline-field"> |
| 249 |
<label>Should login to the web app be enabled?</label> |
| 250 |
<div class="cg-btn-group"> |
| 251 |
<label><input type="radio" name="cg-login-mode" value="disabled" checked><span>Disabled</span></label> |
| 252 |
<label><input type="radio" name="cg-login-mode" value="enabled"><span>Enabled</span></label> |
| 253 |
<label><input type="radio" name="cg-login-mode" value="required"><span>Required</span></label> |
| 254 |
</div> |
| 255 |
</div> |
| 256 |
<div class="cg-field cg-inline-field"> |
| 257 |
<label>Should it be possible to sign up via the web app?</label> |
| 258 |
<div class="cg-btn-group"> |
| 259 |
<label><input type="radio" name="cg-enable-signup" value="no" checked><span>No</span></label> |
| 260 |
<label><input type="radio" name="cg-enable-signup" value="yes"><span>Yes</span></label> |
| 261 |
</div> |
| 262 |
</div> |
| 263 |
<input type="hidden" data-key="auth-default-access"> |
| 264 |
<input type="checkbox" data-key="enable-login" id="cg-enable-login-hidden" style="display:none"> |
| 265 |
<input type="checkbox" data-key="require-login" id="cg-require-login-hidden" style="display:none"> |
| 266 |
<input type="checkbox" data-key="enable-signup" id="cg-enable-signup-hidden" style="display:none"> |
| 267 |
<div class="cg-field"> |
| 268 |
<label>Provisioned users <a href="/config/#users-and-roles" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 269 |
<div class="cg-repeatable-container" id="cg-auth-users-container"></div> |
| 270 |
<button type="button" class="cg-btn-add" data-add-type="user">+ Add user</button> |
| 271 |
</div> |
| 272 |
<div class="cg-field"> |
| 273 |
<label>Provisioned ACLs <a href="/config/#access-control-list-acl" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 274 |
<div class="cg-repeatable-container" id="cg-auth-acls-container"></div> |
| 275 |
<button type="button" class="cg-btn-add" data-add-type="acl">+ Add ACL</button> |
| 276 |
</div> |
| 277 |
<div class="cg-field"> |
| 278 |
<label>Provisioned tokens <a href="/config/#access-tokens" target="_blank" class="cg-help"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" fill="currentColor" viewBox="0 0 16 16"><path d="M16 8A8 8 0 1 1 0 8a8 8 0 0 1 16 0M5.496 6.033h.825c.138 0 .248-.113.266-.25.09-.656.54-1.134 1.342-1.134.686 0 1.314.343 1.314 1.168 0 .635-.374.927-.965 1.371-.673.489-1.206 1.06-1.168 1.987l.003.217a.25.25 0 0 0 .25.246h.811a.25.25 0 0 0 .25-.25v-.105c0-.718.273-.927 1.01-1.486.609-.463 1.244-.977 1.244-2.056 0-1.511-1.276-2.241-2.673-2.241-1.267 0-2.655.59-2.75 2.286a.237.237 0 0 0 .241.247m2.325 6.443c.61 0 1.029-.394 1.029-.927 0-.552-.42-.94-1.029-.94-.584 0-1.009.388-1.009.94 0 .533.425.927 1.01.927z"/></svg></a></label> |
| 279 |
<div class="cg-repeatable-container" id="cg-auth-tokens-container"></div> |
| 280 |
<button type="button" class="cg-btn-add" data-add-type="token">+ Add token</button> |
| 281 |
</div> |
| 282 |
</div> |
| 283 |
<div class="cg-panel" id="cg-panel-cache"> |
| 284 |
<div class="cg-panel-desc">Configure the message cache to allow devices to retrieve missed notifications. See <a href="/config/#message-cache" target="_blank">message cache</a> for details.</div> |
| 285 |
<div class="cg-field cg-inline-field" id="cg-cache-file-field"> |
| 286 |
<label>Where should the cache be stored?</label> |
| 287 |
<input type="text" data-key="cache-file" placeholder="/var/cache/ntfy/cache.db"> |
| 288 |
</div> |
| 289 |
<div class="cg-field cg-inline-field"> |
| 290 |
<label>How long should messages be cached?</label> |
| 291 |
<input type="text" data-key="cache-duration" placeholder="12h"> |
| 292 |
</div> |
| 293 |
</div> |
| 294 |
<div class="cg-panel" id="cg-panel-attach"> |
| 295 |
<div class="cg-panel-desc">Allow users to upload and attach files to notifications. See <a href="/config/#attachments" target="_blank">attachments</a> for details.</div> |
| 296 |
<div class="cg-field cg-inline-field"> |
| 297 |
<label>Where should attachments be stored?</label> |
| 298 |
<input type="text" data-key="attachment-cache-dir" placeholder="/var/cache/ntfy/attachments"> |
| 299 |
</div> |
| 300 |
<div class="cg-field cg-inline-field"> |
| 301 |
<label>Max file size per attachment?</label> |
| 302 |
<input type="text" data-key="attachment-file-size-limit" placeholder="15M"> |
| 303 |
</div> |
| 304 |
<div class="cg-field cg-inline-field"> |
| 305 |
<label>Total attachment storage limit?</label> |
| 306 |
<input type="text" data-key="attachment-total-size-limit" placeholder="5G"> |
| 307 |
</div> |
| 308 |
<div class="cg-field cg-inline-field"> |
| 309 |
<label>How long before attachments expire?</label> |
| 310 |
<input type="text" data-key="attachment-expiry-duration" placeholder="3h"> |
| 311 |
</div> |
| 312 |
</div> |
| 313 |
<div class="cg-panel" id="cg-panel-webpush"> |
| 314 |
<div class="cg-panel-desc">Enable browser push notifications via the Web Push API. VAPID keys are generated automatically. See <a href="/config/#web-push" target="_blank">web push</a> for details.</div> |
| 315 |
<div class="cg-field cg-inline-field"> |
| 316 |
<label>Where should web push data be stored?</label> |
| 317 |
<input type="text" data-key="web-push-file" placeholder="/var/lib/ntfy/webpush.db"> |
| 318 |
</div> |
| 319 |
<div class="cg-field cg-inline-field"> |
| 320 |
<label>Contact email address</label> |
| 321 |
<input type="text" data-key="web-push-email-address" placeholder="[email protected]"> |
| 322 |
</div> |
| 323 |
<div class="cg-field cg-inline-field"> |
| 324 |
<label>Private key</label> |
| 325 |
<input type="text" data-key="web-push-private-key" placeholder="Auto-generated" readonly> |
| 326 |
</div> |
| 327 |
<div class="cg-field cg-inline-field"> |
| 328 |
<label>Public key</label> |
| 329 |
<input type="text" data-key="web-push-public-key" placeholder="Auto-generated" readonly> |
| 330 |
</div> |
| 331 |
<div class="cg-field cg-inline-field"> |
| 332 |
<label></label> |
| 333 |
<button type="button" id="cg-regen-keys" class="cg-btn-add">Regenerate keys</button> |
| 334 |
</div> |
| 335 |
</div> |
| 336 |
<div class="cg-panel" id="cg-panel-email"> |
| 337 |
<div class="cg-panel-desc">Configure outgoing email notifications and/or incoming email publishing. See <a href="/config/#e-mail-notifications" target="_blank">email notifications</a> and <a href="/config/#e-mail-publishing" target="_blank">email publishing</a> for details.</div> |
| 338 |
<div id="cg-email-out-section" class="cg-hidden"> |
| 339 |
<div class="cg-field"><label><strong>Outgoing (notifications)</strong></label></div> |
| 340 |
<div class="cg-field cg-inline-field"> |
| 341 |
<label>SMTP server address</label> |
| 342 |
<input type="text" data-key="smtp-sender-addr" placeholder="smtp.example.com:587"> |
| 343 |
</div> |
| 344 |
<div class="cg-field cg-inline-field"> |
| 345 |
<label>Sender email</label> |
| 346 |
<input type="text" data-key="smtp-sender-from" placeholder="[email protected]"> |
| 347 |
</div> |
| 348 |
<div class="cg-field cg-inline-field"> |
| 349 |
<label>SMTP username</label> |
| 350 |
<input type="text" data-key="smtp-sender-user" placeholder="Username"> |
| 351 |
</div> |
| 352 |
<div class="cg-field cg-inline-field"> |
| 353 |
<label>SMTP password</label> |
| 354 |
<input type="password" data-key="smtp-sender-pass" placeholder="Password"> |
| 355 |
</div> |
| 356 |
<div class="cg-field cg-inline-field"> |
| 357 |
<label>Require email verification</label> |
| 358 |
<div class="cg-btn-group"> |
| 359 |
<label><input type="radio" name="cg-smtp-sender-verify" value="no" checked><span>No</span></label> |
| 360 |
<label><input type="radio" name="cg-smtp-sender-verify" value="yes"><span>Yes</span></label> |
| 361 |
</div> |
| 362 |
</div> |
| 363 |
<input type="checkbox" data-key="smtp-sender-verify" id="cg-smtp-sender-verify-hidden" style="display:none"> |
| 364 |
</div> |
| 365 |
<div id="cg-email-in-section" class="cg-hidden"> |
| 366 |
<div class="cg-field"><label><strong>Incoming (publishing)</strong></label></div> |
| 367 |
<div class="cg-field cg-inline-field"> |
| 368 |
<label>Listen address</label> |
| 369 |
<input type="text" data-key="smtp-server-listen" placeholder=":25"> |
| 370 |
</div> |
| 371 |
<div class="cg-field cg-inline-field"> |
| 372 |
<label>Domain</label> |
| 373 |
<input type="text" data-key="smtp-server-domain" placeholder="ntfy.example.com"> |
| 374 |
</div> |
| 375 |
<div class="cg-field cg-inline-field"> |
| 376 |
<label>Address prefix</label> |
| 377 |
<input type="text" data-key="smtp-server-addr-prefix" placeholder="ntfy-"> |
| 378 |
</div> |
| 379 |
</div> |
| 380 |
</div> |
| 381 |
<div class="cg-panel" id="cg-panel-database"> |
| 382 |
<div class="cg-panel-desc">Configure the PostgreSQL connection. See <a href="/config/#postgresql" target="_blank">PostgreSQL</a> for details.</div> |
| 383 |
<div class="cg-field"> |
| 384 |
<label>Database URL</label> |
| 385 |
<input type="text" data-key="database-url" placeholder="postgres://user:pass@host:5432/ntfy"> |
| 386 |
</div> |
| 387 |
</div> |
| 388 |
<input type="hidden" data-key="upstream-base-url"> |
| 389 |
<input type="checkbox" data-key="behind-proxy" id="cg-behind-proxy" style="display:none"> |
| 390 |
</div> |
| 391 |
</div> |
| 392 |
<div id="cg-right"> |
| 393 |
<div class="cg-output-tabs"> |
| 394 |
<div class="cg-output-tab active" data-format="server-yml">server.yml</div> |
| 395 |
<div class="cg-output-tab" data-format="docker-compose">docker-compose.yml</div> |
| 396 |
<div class="cg-output-tab" data-format="env-vars">Env variables</div> |
| 397 |
<button type="button" id="cg-copy-btn" class="cg-btn-copy" title="Copy to clipboard"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path></svg></button> |
| 398 |
</div> |
| 399 |
<div class="cg-output-wrap"> |
| 400 |
<pre><code id="cg-code"><span class="cg-empty-msg">Configure options on the left to generate your config...</span></code></pre> |
| 401 |
<div id="cg-warnings" class="cg-hidden"></div> |
| 402 |
</div> |
| 403 |
</div> |
| 404 |
</div> |
| 405 |
</div> |
| 406 |
</div> |
| 407 |
|
| 408 |
## Database options |
| 409 |
ntfy uses a database for storing messages ([message cache](#message-cache)), users and [access control](#access-control), and [web push](#web-push) subscriptions. |
| 410 |
You can choose between **SQLite** and **PostgreSQL** as the database backend. |
| 411 |
|
| 412 |
### SQLite |
| 413 |
By default, ntfy uses SQLite with separate database files for each store. This is the simplest setup and requires |
| 414 |
no external dependencies: |
| 415 |
|
| 416 |
* `cache-file`: Database file for the [message cache](#message-cache). |
| 417 |
* `auth-file`: Database file for authentication and [access control](#access-control). If set, enables auth. |
| 418 |
* `web-push-file`: Database file for [web push](#web-push) subscriptions. |
| 419 |
|
| 420 |
### PostgreSQL |
| 421 |
As an alternative, you can configure ntfy to use PostgreSQL for **all** database-backed stores by setting the |
| 422 |
`database-url` option to a PostgreSQL connection string. |
| 423 |
|
| 424 |
When `database-url` is set, ntfy will use PostgreSQL for the [message cache](#message-cache), |
| 425 |
[access control](#access-control), and [web push](#web-push) subscriptions instead of SQLite. The `cache-file`, |
| 426 |
`auth-file`, and `web-push-file` options **must not** be set in this case. |
| 427 |
|
| 428 |
Note that setting `database-url` implicitly enables authentication and access control (equivalent to setting |
| 429 |
`auth-file` with SQLite). The default access is `read-write`, so anonymous users can still read and write to all |
| 430 |
topics. To restrict access, set `auth-default-access` to `deny-all` (see [access control](#access-control)). |
| 431 |
|
| 432 |
You can also set this via the environment variable `NTFY_DATABASE_URL` or the command line flag `--database-url`. |
| 433 |
|
| 434 |
To offload read-heavy queries from the primary database, you can optionally configure one or more read replicas |
| 435 |
using the `database-replica-urls` option. When configured, non-critical read-only queries (e.g. fetching messages, checking access permissions, etc) |
| 436 |
are distributed across the replicas using round-robin, while all writes and correctness-critical reads continue to go |
| 437 |
to the primary. If a replica becomes unhealthy, ntfy automatically falls back to the primary until the replica recovers. |
| 438 |
You can also set this via the environment variable `NTFY_DATABASE_REPLICA_URLS` (comma-separated) or the command line |
| 439 |
flag `--database-replica-urls`. |
| 440 |
|
| 441 |
Examples: |
| 442 |
|
| 443 |
=== "Simple" |
| 444 |
```yaml |
| 445 |
database-url: "postgres://user:pass@host:5432/ntfy" |
| 446 |
``` |
| 447 |
|
| 448 |
=== "With SSL and pool tuning" |
| 449 |
```yaml |
| 450 |
database-url: "postgres://user:pass@host:5432/ntfy?sslmode=require&pool_max_conns=50&pool_conn_max_idle_time=5m" |
| 451 |
``` |
| 452 |
|
| 453 |
=== "With CA certificate" |
| 454 |
```yaml |
| 455 |
database-url: "postgres://user:pass@host:25060/ntfy?sslmode=require&sslrootcert=/etc/ntfy/db-ca-cert.pem&pool_max_conns=30" |
| 456 |
``` |
| 457 |
|
| 458 |
=== "With read replicas" |
| 459 |
```yaml |
| 460 |
database-url: "postgres://user:pass@primary:5432/ntfy?sslmode=require&sslrootcert=/etc/ntfy/db-ca-cert.pem&pool_max_conns=30" |
| 461 |
database-replica-urls: |
| 462 |
- "postgres://user:pass@replica1:5432/ntfy?sslmode=require&sslrootcert=/etc/ntfy/db-ca-cert.pem&pool_max_conns=30" |
| 463 |
- "postgres://user:pass@replica2:5432/ntfy?sslmode=require&sslrootcert=/etc/ntfy/db-ca-cert.pem&pool_max_conns=30" |
| 464 |
``` |
| 465 |
|
| 466 |
The database URL supports the standard [PostgreSQL connection parameters](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS) |
| 467 |
as query parameters, such as `sslmode`, `connect_timeout`, `sslcert`, `sslkey`, `sslrootcert`, and `application_name`. |
| 468 |
See the [pgx driver documentation](https://pkg.go.dev/github.com/jackc/pgx/v5) for the full list of supported parameters. |
| 469 |
|
| 470 |
In addition, ntfy supports the following custom query parameters to tune the connection pool (these apply to both |
| 471 |
the primary and replica URLs): |
| 472 |
|
| 473 |
| Parameter | Default | Description | |
| 474 |
|---------------------------|---------|----------------------------------------------------------------------------------| |
| 475 |
| `pool_max_conns` | 10 | Maximum number of open connections to the database | |
| 476 |
| `pool_max_idle_conns` | - | Maximum number of idle connections in the pool | |
| 477 |
| `pool_conn_max_lifetime` | - | Maximum amount of time a connection may be reused (Go duration, e.g. `5m`, `1h`) | |
| 478 |
| `pool_conn_max_idle_time` | - | Maximum amount of time a connection may be idle (Go duration, e.g. `30s`, `5m`) | |
| 479 |
|
| 480 |
|
| 481 |
## Message cache |
| 482 |
If desired, ntfy can temporarily keep notifications in an in-memory or an on-disk cache. Caching messages for a short period |
| 483 |
of time is important to allow [phones](subscribe/phone.md) and other devices with brittle Internet connections to be able to retrieve |
| 484 |
notifications that they may have missed. |
| 485 |
|
| 486 |
By default, ntfy keeps messages **in-memory for 12 hours**, which means that **cached messages do not survive an application |
| 487 |
restart**. You can override this behavior by setting `cache-file` (SQLite) or `database-url` (PostgreSQL). |
| 488 |
|
| 489 |
* `cache-duration`: defines the duration for which messages are stored in the cache (default is `12h`). |
| 490 |
|
| 491 |
You can also entirely disable the cache by setting `cache-duration` to `0`. When the cache is disabled, messages are only |
| 492 |
passed on to the connected subscribers, but never stored on disk or even kept in memory longer than is needed to forward |
| 493 |
the message to the subscribers. |
| 494 |
|
| 495 |
Subscribers can retrieve cached messaging using the [`poll=1` parameter](subscribe/api.md#poll-for-messages), as well as the |
| 496 |
[`since=` parameter](subscribe/api.md#fetch-cached-messages). |
| 497 |
|
| 498 |
## Attachments |
| 499 |
If desired, you may allow users to upload and [attach files to notifications](publish.md#attachments). To enable |
| 500 |
this feature, you have to configure an attachment storage backend and a base URL (`base-url`). Attachments can be stored |
| 501 |
either on the [local filesystem](#filesystem-storage) or in an [S3-compatible object store](#s3-storage), both using the `attachment-cache-dir` option. |
| 502 |
Once configured, you can upload attachments via PUT. |
| 503 |
|
| 504 |
By default, attachments are stored **for only 3 hours**. The main reason for this is to avoid legal issues |
| 505 |
and such when hosting user controlled content. Typically, this is more than enough time for the user (or the auto download |
| 506 |
feature) to download the file. You can increase this time by [purchasing ntfy Pro](https://ntfy.sh/app) via the web app. |
| 507 |
|
| 508 |
The following config options are relevant to attachments: |
| 509 |
|
| 510 |
* `base-url` is the root URL for the ntfy server; this is needed for the generated attachment URLs |
| 511 |
* `attachment-cache-dir` is the cache directory for attached files, or an S3 URL for object storage |
| 512 |
* `attachment-total-size-limit` is the size limit of the attachment storage (default: 5G) |
| 513 |
* `attachment-file-size-limit` is the per-file attachment size limit (e.g. 300k, 2M, 100M, default: 15M) |
| 514 |
* `attachment-expiry-duration` is the duration after which uploaded attachments will be deleted (e.g. 3h, 20h, default: 3h) |
| 515 |
|
| 516 |
!!! warning |
| 517 |
ntfy takes full control over the attachment directory or S3 bucket. Files that match the message ID format without |
| 518 |
entries in the message table will be deleted. **Do not use a directory or S3 bucket that is also used for something else.** |
| 519 |
|
| 520 |
Please also refer to the [rate limiting](#rate-limiting) settings below, specifically `visitor-attachment-total-size-limit` |
| 521 |
and `visitor-attachment-daily-bandwidth-limit`. Setting these conservatively is necessary to avoid abuse. |
| 522 |
|
| 523 |
### Filesystem storage |
| 524 |
Here's an example config using the local filesystem for attachment storage: |
| 525 |
|
| 526 |
=== "/etc/ntfy/server.yml (minimal)" |
| 527 |
``` yaml |
| 528 |
base-url: "https://ntfy.example.com" |
| 529 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 530 |
``` |
| 531 |
|
| 532 |
=== "/etc/ntfy/server.yml (all options)" |
| 533 |
``` yaml |
| 534 |
base-url: "https://ntfy.example.com" |
| 535 |
attachment-cache-dir: "/var/cache/ntfy/attachments" |
| 536 |
attachment-total-size-limit: "5G" |
| 537 |
attachment-file-size-limit: "15M" |
| 538 |
attachment-expiry-duration: "3h" |
| 539 |
visitor-attachment-total-size-limit: "100M" |
| 540 |
visitor-attachment-daily-bandwidth-limit: "500M" |
| 541 |
``` |
| 542 |
|
| 543 |
### S3 storage |
| 544 |
As an alternative to the local filesystem, you can store attachments in an S3-compatible object store (e.g. [AWS S3](https://aws.amazon.com/s3/), |
| 545 |
[DigitalOcean Spaces](https://www.digitalocean.com/products/spaces)). This is useful for HA/cloud deployments where you don't want to rely on local disk storage. |
| 546 |
To use an S3-compatible storage for attachments, set `attachment-cache-dir` to an S3 URL with the following format: |
| 547 |
|
| 548 |
``` |
| 549 |
s3://ACCESS_KEY:SECRET_KEY@BUCKET[/PREFIX]?region=REGION[&endpoint=ENDPOINT][&disable_http2=true] |
| 550 |
``` |
| 551 |
|
| 552 |
Here are a few examples: |
| 553 |
|
| 554 |
=== "/etc/ntfy/server.yml (DigitalOcean Spaces)" |
| 555 |
``` yaml |
| 556 |
base-url: "https://ntfy.example.com" |
| 557 |
attachment-cache-dir: "s3://ACCESS_KEY:SECRET_KEY@my-bucket/attachments?region=nyc3&endpoint=https://nyc3.digitaloceanspaces.com&disable_http2=true" |
| 558 |
``` |
| 559 |
|
| 560 |
=== "/etc/ntfy/server.yml (AWS S3)" |
| 561 |
``` yaml |
| 562 |
base-url: "https://ntfy.example.com" |
| 563 |
attachment-cache-dir: "s3://ACCESS_KEY:SECRET_KEY@my-bucket/attachments?region=us-east-1" |
| 564 |
``` |
| 565 |
|
| 566 |
=== "/etc/ntfy/server.yml (custom endpoint)" |
| 567 |
``` yaml |
| 568 |
base-url: "https://ntfy.example.com" |
| 569 |
attachment-cache-dir: "s3://ACCESS_KEY:SECRET_KEY@my-bucket/attachments?region=us-east-1&endpoint=https://s3.example.com" |
| 570 |
``` |
| 571 |
|
| 572 |
Note that the access key and secret key may have to be URL encoded. For instance, a secret key `YmxhY+mxhYmxhC` (note the `+`) should |
| 573 |
be encoded as `YmxhY%2BmxhYmxhC` (note the `%2B`), so the URL would be `s3://ACCESS_KEY:YmxhY%2BmxhYmxhC@my-bucket/attachments...`. |
| 574 |
|
| 575 |
If you experience upload failures with HTTP/2 stream errors (common with DigitalOcean Spaces and some other S3-compatible providers), |
| 576 |
add `&disable_http2=true` to force HTTP/1.1 connections. |
| 577 |
|
| 578 |
!!! info |
| 579 |
ntfy.sh is hosted and sponsored by DigitalOcean. I can highly recommend their public cloud offering. It's been rock solid |
| 580 |
for 4 years. They offer an S3-compatible storage for $5/month and 250 GB of storage, with 1 TiB of bandwidth. |
| 581 |
Also, if you **use [this referral link](https://m.do.co/c/442b929528db), you can get $200 credit**. |
| 582 |
|
| 583 |
For AWS S3, the IAM user needs the following permissions on the bucket: |
| 584 |
|
| 585 |
``` json |
| 586 |
{ |
| 587 |
"Version": "2012-10-17", |
| 588 |
"Statement": [ |
| 589 |
{ |
| 590 |
"Effect": "Allow", |
| 591 |
"Action": [ |
| 592 |
"s3:ListBucket", |
| 593 |
"s3:ListBucketMultipartUploads" |
| 594 |
], |
| 595 |
"Resource": "arn:aws:s3:::BUCKET_NAME" |
| 596 |
}, |
| 597 |
{ |
| 598 |
"Effect": "Allow", |
| 599 |
"Action": [ |
| 600 |
"s3:GetObject", |
| 601 |
"s3:PutObject", |
| 602 |
"s3:DeleteObject", |
| 603 |
"s3:AbortMultipartUpload" |
| 604 |
], |
| 605 |
"Resource": "arn:aws:s3:::BUCKET_NAME/*" |
| 606 |
} |
| 607 |
] |
| 608 |
} |
| 609 |
``` |
| 610 |
|
| 611 |
## Access control |
| 612 |
By default, the ntfy server is open for everyone, meaning **everyone can read and write to any topic** (this is how |
| 613 |
ntfy.sh is configured). To restrict access to your own server, you can optionally configure authentication and authorization. |
| 614 |
|
| 615 |
ntfy's auth implements two roles (`user` and `admin`) and per-topic `read` and `write` permissions using an |
| 616 |
[access control list (ACL)](https://en.wikipedia.org/wiki/Access-control_list). Access control entries can be applied |
| 617 |
to users as well as the special everyone user (`*`), which represents anonymous API access. |
| 618 |
|
| 619 |
To set up auth, **configure the following options**: |
| 620 |
|
| 621 |
* `auth-file` is the user/access database (SQLite); it is created automatically if it doesn't already exist; suggested |
| 622 |
location `/var/lib/ntfy/user.db` (easiest if deb/rpm package is used). Alternatively, if `database-url` is set, |
| 623 |
auth is automatically enabled using PostgreSQL (see [database options](#database-options)). |
| 624 |
* `auth-default-access` defines the default/fallback access if no access control entry is found; it can be |
| 625 |
set to `read-write` (default), `read-only`, `write-only` or `deny-all`. **If you are setting up a private instance, |
| 626 |
you'll want to set this to `deny-all`** (see [private instance example](#example-private-instance)). |
| 627 |
|
| 628 |
Once configured, you can use |
| 629 |
|
| 630 |
- the `ntfy user` command and the `auth-users` config option to [add or modify users](#users-and-roles) |
| 631 |
- the `ntfy access` command and the `auth-access` option to [modify the access control list](#access-control-list-acl) |
| 632 |
and topic patterns, and |
| 633 |
- the `ntfy token` command and the `auth-tokens` config option to [manage access tokens](#access-tokens) for users. |
| 634 |
|
| 635 |
These commands **directly edit the auth database** (as defined in `auth-file`), so they only work on the server, |
| 636 |
and only if the user accessing them has the right permissions. |
| 637 |
|
| 638 |
### Users and roles |
| 639 |
Users can be added to the ntfy user database in two different ways |
| 640 |
|
| 641 |
* [Using the CLI](#users-via-the-cli): Using the `ntfy user` command, you can manually add/update/remove users. |
| 642 |
* [In the config](#users-via-the-config): You can provision users in the `server.yml` file via `auth-users` key. |
| 643 |
|
| 644 |
#### Users via the CLI |
| 645 |
The `ntfy user` command allows you to add/remove/change users in the ntfy user database, as well as change |
| 646 |
passwords or roles (`user` or `admin`). In practice, you'll often just create one admin |
| 647 |
user with `ntfy user add --role=admin ...` and be done with all this (see [example below](#example-private-instance)). |
| 648 |
|
| 649 |
**Roles:** |
| 650 |
|
| 651 |
* Role `user` (default): Users with this role have no special permissions. Manage access using `ntfy access` |
| 652 |
(see [below](#access-control-list-acl)). |
| 653 |
* Role `admin`: Users with this role can read/write to all topics. Granular access control is not necessary. |
| 654 |
|
| 655 |
**Example commands** (type `ntfy user --help` or `ntfy user COMMAND --help` for more details): |
| 656 |
|
| 657 |
``` |
| 658 |
ntfy user list # Shows list of users (alias: 'ntfy access') |
| 659 |
ntfy user add phil # Add regular user phil |
| 660 |
ntfy user add --role=admin phil # Add admin user phil |
| 661 |
ntfy user del phil # Delete user phil |
| 662 |
ntfy user change-pass phil # Change password for user phil |
| 663 |
ntfy user change-role phil admin # Make user phil an admin |
| 664 |
ntfy user change-tier phil pro # Change phil's tier to "pro" |
| 665 |
ntfy user hash # Generate password hash, use with auth-users config option |
| 666 |
``` |
| 667 |
|
| 668 |
#### Users via the config |
| 669 |
As an alternative to manually creating users via the `ntfy user` CLI command, you can provision users declaratively in |
| 670 |
the `server.yml` file by adding them to the `auth-users` array. This is useful for general admins, or if you'd like to |
| 671 |
deploy your ntfy server via Docker/Ansible without manually editing the database. |
| 672 |
|
| 673 |
The `auth-users` option is a list of users that are automatically created/updated when the server starts. Users |
| 674 |
previously defined in the config but later removed will be deleted. Each entry is defined in the format `<username>:<password-hash>:<role>`. |
| 675 |
|
| 676 |
Here's an example with two users: `phil` is an admin, `ben` is a regular user. |
| 677 |
|
| 678 |
=== "Declarative users in /etc/ntfy/server.yml" |
| 679 |
``` yaml |
| 680 |
auth-file: "/var/lib/ntfy/user.db" |
| 681 |
auth-users: |
| 682 |
- "phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin" |
| 683 |
- "ben:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user" |
| 684 |
``` |
| 685 |
|
| 686 |
=== "Declarative users via env variables" |
| 687 |
``` |
| 688 |
# Comma-separated list, use single quotes to avoid issues with the bcrypt hash |
| 689 |
NTFY_AUTH_FILE='/var/lib/ntfy/user.db' |
| 690 |
NTFY_AUTH_USERS='phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin,ben:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user' |
| 691 |
``` |
| 692 |
|
| 693 |
The password hash can be created using `ntfy user hash` or an [online bcrypt generator](https://bcrypt-generator.com/) (though |
| 694 |
note that you're putting your password in an untrusted website). |
| 695 |
|
| 696 |
!!! important |
| 697 |
Users added declaratively via the config file are marked in the database as "provisioned users". Removing users |
| 698 |
from the config file will **delete them from the database** the next time ntfy is restarted. |
| 699 |
|
| 700 |
Also, users that were originally manually created will be "upgraded" to be provisioned users if they are added to |
| 701 |
the config. Adding a user manually, then adding it to the config, and then removing it from the config will hence |
| 702 |
lead to the **deletion of that user**. |
| 703 |
|
| 704 |
### Access control list (ACL) |
| 705 |
The access control list (ACL) **manages access to topics for non-admin users, and for anonymous access (`everyone`/`*`)**. |
| 706 |
Each entry represents the access permissions for a user to a specific topic or topic pattern. Entries can be created in |
| 707 |
two different ways: |
| 708 |
|
| 709 |
* [Using the CLI](#acl-entries-via-the-cli): Using the `ntfy access` command, you can manually edit the access control list. |
| 710 |
* [In the config](#acl-entries-via-the-config): You can provision ACL entries in the `server.yml` file via `auth-access` key. |
| 711 |
|
| 712 |
#### ACL entries via the CLI |
| 713 |
The ACL can be displayed or modified with the `ntfy access` command: |
| 714 |
|
| 715 |
``` |
| 716 |
ntfy access # Shows access control list (alias: 'ntfy user list') |
| 717 |
ntfy access USERNAME # Shows access control entries for USERNAME |
| 718 |
ntfy access USERNAME TOPIC PERMISSION # Allow/deny access for USERNAME to TOPIC |
| 719 |
``` |
| 720 |
|
| 721 |
A `USERNAME` is an existing user, as created with `ntfy user add` (see [users and roles](#users-and-roles)), or the |
| 722 |
anonymous user `everyone` or `*`, which represents clients that access the API without username/password. |
| 723 |
|
| 724 |
A `TOPIC` is either a specific topic name (e.g. `mytopic`, or `phil_alerts`), or a wildcard pattern that matches any |
| 725 |
number of topics (e.g. `alerts_*` or `ben-*`). Only the wildcard character `*` is supported. It stands for zero to any |
| 726 |
number of characters. |
| 727 |
|
| 728 |
A `PERMISSION` is any of the following supported permissions: |
| 729 |
|
| 730 |
* `read-write` (alias: `rw`): Allows [publishing messages](publish.md) to the given topic, as well as |
| 731 |
[subscribing](subscribe/api.md) and reading messages |
| 732 |
* `read-only` (aliases: `read`, `ro`): Allows only subscribing and reading messages, but not publishing to the topic |
| 733 |
* `write-only` (aliases: `write`, `wo`): Allows only publishing to the topic, but not subscribing to it |
| 734 |
* `deny` (alias: `none`): Allows neither publishing nor subscribing to a topic |
| 735 |
|
| 736 |
**Example commands** (type `ntfy access --help` for more details): |
| 737 |
``` |
| 738 |
ntfy access # Shows entire access control list |
| 739 |
ntfy access phil # Shows access for user phil |
| 740 |
ntfy access phil mytopic rw # Allow read-write access to mytopic for user phil |
| 741 |
ntfy access everyone mytopic rw # Allow anonymous read-write access to mytopic |
| 742 |
ntfy access everyone "up*" write # Allow anonymous write-only access to topics "up..." |
| 743 |
ntfy access --reset # Reset entire access control list |
| 744 |
ntfy access --reset phil # Reset all access for user phil |
| 745 |
ntfy access --reset phil mytopic # Reset access for user phil and topic mytopic |
| 746 |
``` |
| 747 |
|
| 748 |
**Example ACL:** |
| 749 |
``` |
| 750 |
$ ntfy access |
| 751 |
user phil (admin) |
| 752 |
- read-write access to all topics (admin role) |
| 753 |
user ben (user) |
| 754 |
- read-write access to topic garagedoor |
| 755 |
- read-write access to topic alerts* |
| 756 |
- read-only access to topic furnace |
| 757 |
user * (anonymous) |
| 758 |
- read-only access to topic announcements |
| 759 |
- read-only access to topic server-stats |
| 760 |
- no access to any (other) topics (server config) |
| 761 |
``` |
| 762 |
|
| 763 |
In this example, `phil` has the role `admin`, so he has read-write access to all topics (no ACL entries are necessary). |
| 764 |
User `ben` has three topic-specific entries. He can read, but not write to topic `furnace`, and has read-write access |
| 765 |
to topic `garagedoor` and all topics starting with the word `alerts` (wildcards). Clients that are not authenticated |
| 766 |
(called `*`/`everyone`) only have read access to the `announcements` and `server-stats` topics. |
| 767 |
|
| 768 |
#### ACL entries via the config |
| 769 |
As an alternative to manually creating ACL entries via the `ntfy access` CLI command, you can provision access control |
| 770 |
entries declaratively in the `server.yml` file by adding them to the `auth-access` array, similar to the `auth-users` |
| 771 |
option (see [users via the config](#users-via-the-config). |
| 772 |
|
| 773 |
The `auth-access` option is a list of access control entries that are automatically created/updated when the server starts. |
| 774 |
When entries are removed, they are deleted from the database. Each entry is defined in the format `<username>:<topic-pattern>:<access>`. |
| 775 |
|
| 776 |
The `<username>` can be any existing, provisioned user as defined in the `auth-users` section (see [users via the config](#users-via-the-config)), |
| 777 |
or `everyone`/`*` for anonymous access. The `<topic-pattern>` can be a specific topic name or a pattern with wildcards (`*`). The |
| 778 |
`<access>` can be one of the following: |
| 779 |
|
| 780 |
* `read-write` or `rw`: Allows both publishing to and subscribing to the topic |
| 781 |
* `read-only`, `read`, or `ro`: Allows only subscribing to the topic |
| 782 |
* `write-only`, `write`, or `wo`: Allows only publishing to the topic |
| 783 |
* `deny-all`, `deny`, or `none`: Denies all access to the topic |
| 784 |
|
| 785 |
Here's an example with several ACL entries: |
| 786 |
|
| 787 |
=== "Declarative ACL entries in /etc/ntfy/server.yml" |
| 788 |
``` yaml |
| 789 |
auth-file: "/var/lib/ntfy/user.db" |
| 790 |
auth-users: |
| 791 |
- "phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:user" |
| 792 |
- "ben:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user" |
| 793 |
auth-access: |
| 794 |
- "phil:mytopic:rw" |
| 795 |
- "ben:alerts-*:rw" |
| 796 |
- "ben:system-logs:ro" |
| 797 |
- "*:announcements:ro" # or: "everyone:announcements,ro" |
| 798 |
``` |
| 799 |
|
| 800 |
=== "Declarative ACL entries via env variables" |
| 801 |
``` |
| 802 |
# Comma-separated list |
| 803 |
NTFY_AUTH_FILE='/var/lib/ntfy/user.db' |
| 804 |
NTFY_AUTH_USERS='phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:user,ben:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user' |
| 805 |
NTFY_AUTH_ACCESS='phil:mytopic:rw,ben:alerts-*:rw,ben:system-logs:ro,*:announcements:ro' |
| 806 |
``` |
| 807 |
|
| 808 |
In this example, the `auth-users` section defines two users, `phil` and `ben`. The `auth-access` section defines |
| 809 |
access control entries for these users. `phil` has read-write access to the topic `mytopic`, while `ben` has read-write |
| 810 |
access to all topics starting with `alerts-` and read-only access to the topic `system-logs`. The last entry allows |
| 811 |
anonymous users (i.e. clients that do not authenticate) to read the `announcements` topic. |
| 812 |
|
| 813 |
### Access tokens |
| 814 |
In addition to username/password auth, ntfy also provides authentication via access tokens. Access tokens are useful |
| 815 |
to avoid having to configure your password across multiple publishing/subscribing applications. For instance, you may |
| 816 |
want to use a dedicated token to publish from your backup host, and one from your home automation system. |
| 817 |
|
| 818 |
!!! info |
| 819 |
As of today, access tokens grant users **full access to the user account**. Aside from changing the password, |
| 820 |
and deleting the account, every action can be performed with a token. Granular access tokens are on the roadmap, |
| 821 |
but not yet implemented. |
| 822 |
|
| 823 |
You can create access tokens in two different ways: |
| 824 |
|
| 825 |
* [Using the CLI](#tokens-via-the-cli): Using the `ntfy token` command, you can manually add/update/remove tokens. |
| 826 |
* [In the config](#tokens-via-the-config): You can provision access tokens in the `server.yml` file via `auth-tokens` key. |
| 827 |
|
| 828 |
#### Tokens via the CLI |
| 829 |
The `ntfy token` command can be used to manage access tokens for users. Tokens can have labels, and they can expire |
| 830 |
automatically (or never expire). Each user can have up to 60 tokens (hardcoded). |
| 831 |
|
| 832 |
**Example commands** (type `ntfy token --help` or `ntfy token COMMAND --help` for more details): |
| 833 |
``` |
| 834 |
ntfy token list # Shows list of tokens for all users |
| 835 |
ntfy token list phil # Shows list of tokens for user phil |
| 836 |
ntfy token add phil # Create token for user phil which never expires |
| 837 |
ntfy token add --expires=2d phil # Create token for user phil which expires in 2 days |
| 838 |
ntfy token remove phil tk_th2sxr... # Delete token |
| 839 |
ntfy token generate # Generate random token, can be used in auth-tokens config option |
| 840 |
``` |
| 841 |
|
| 842 |
**Creating an access token:** |
| 843 |
``` |
| 844 |
$ ntfy token add --expires=30d --label="backups" phil |
| 845 |
$ ntfy token list |
| 846 |
user phil |
| 847 |
- tk_7eevizlsiwf9yi4uxsrs83r4352o0 (backups), expires 15 Mar 23 14:33 EDT, accessed from 0.0.0.0 at 13 Feb 23 13:33 EST |
| 848 |
``` |
| 849 |
|
| 850 |
Once an access token is created, you can **use it to authenticate against the ntfy server, e.g. when you publish or |
| 851 |
subscribe to topics**. To learn how, check out [authenticate via access tokens](publish.md#access-tokens). |
| 852 |
|
| 853 |
#### Tokens via the config |
| 854 |
Access tokens can be pre-provisioned in the `server.yml` configuration file using the `auth-tokens` config option. |
| 855 |
This is useful for automated setups, Docker environments, or when you want to define tokens declaratively. |
| 856 |
|
| 857 |
The `auth-tokens` option is a list of access tokens that are automatically created/updated when the server starts. |
| 858 |
When entries are removed, they are deleted from the database. Each entry is defined in the format `<username>:<token>[:<label>]`. |
| 859 |
|
| 860 |
The `<username>` must be an existing, provisioned user, as defined in the `auth-users` section (see [users via the config](#users-via-the-config)). |
| 861 |
The `<token>` is a valid access token, which must start with `tk_` and be 32 characters long (including the prefix). You can generate |
| 862 |
random tokens using the `ntfy token generate` command. The optional `<label>` is a human-readable label for the token, |
| 863 |
which can be used to identify it later. |
| 864 |
|
| 865 |
Once configured, these tokens can be used to authenticate API requests just like tokens created via the CLI. |
| 866 |
For usage examples, see [authenticate via access tokens](publish.md#access-tokens). |
| 867 |
|
| 868 |
Here's an example: |
| 869 |
|
| 870 |
=== "Declarative tokens in /etc/ntfy/server.yml" |
| 871 |
``` yaml |
| 872 |
auth-file: "/var/lib/ntfy/user.db" |
| 873 |
auth-users: |
| 874 |
- "phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin" |
| 875 |
- "backup-service:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user" |
| 876 |
auth-tokens: |
| 877 |
- "phil:tk_3gd7d2yftt4b8ixyfe9mnmro88o76" |
| 878 |
- "backup-service:tk_f099we8uzj7xi5qshzajwp6jffvkz:Backup script" |
| 879 |
``` |
| 880 |
|
| 881 |
=== "Declarative tokens via env variables" |
| 882 |
``` |
| 883 |
# Comma-separated list |
| 884 |
NTFY_AUTH_FILE='/var/lib/ntfy/user.db' |
| 885 |
NTFY_AUTH_USERS='phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin,backup-service:$2a$10$NKbrNb7HPMjtQXWJ0f1pouw03LDLT/WzlO9VAv44x84bRCkh19h6m:user' |
| 886 |
NTFY_AUTH_TOKENS='phil:tk_3gd7d2yftt4b8ixyfe9mnmro88o76,backup-service:tk_f099we8uzj7xi5qshzajwp6jffvkz:Backup script' |
| 887 |
``` |
| 888 |
|
| 889 |
In this example, the `auth-users` section defines two users, `phil` and `backup-service`. The `auth-tokens` section |
| 890 |
defines access tokens for these users. `phil` has a token `tk_3gd7d2yftt4b8ixyfe9mnmro88o76`, while `backup-service` |
| 891 |
has a token `tk_f099we8uzj7xi5qshzajwp6jffvkz` with the label "Backup script". |
| 892 |
|
| 893 |
### Example: Private instance |
| 894 |
The easiest way to configure a private instance is to set `auth-default-access` to `deny-all` in the `server.yml`, |
| 895 |
and to configure users in the `auth-users` section (see [users via the config](#users-via-the-config)), |
| 896 |
access control entries in the `auth-access` section (see [ACL entries via the config](#acl-entries-via-the-config)), |
| 897 |
and access tokens in the `auth-tokens` section (see [access tokens via the config](#tokens-via-the-config)). |
| 898 |
|
| 899 |
Here's an example that defines a single admin user `phil` with the password `mypass`, and a regular user `backup-script` |
| 900 |
with the password `backup-script`. The admin user has full access to all topics, while regular user can only |
| 901 |
access the `backups` topic with read-write permissions. `phil` has a token `tk_3gd7d2yftt4b8ixyfe9mnmro88o76` |
| 902 |
with the label "My personal token". The `auth-default-access` is set to `deny-all`, which means |
| 903 |
that all other users and anonymous access are denied by default. |
| 904 |
|
| 905 |
=== "Config via /etc/ntfy/server.yml" |
| 906 |
``` yaml |
| 907 |
auth-file: "/var/lib/ntfy/user.db" |
| 908 |
auth-default-access: "deny-all" |
| 909 |
auth-users: |
| 910 |
- "phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin" |
| 911 |
- "backup-script:$2a$10$/ehiQt.w7lhTmHXq.RNsOOkIwiPPeWFIzWYO3DRxNixnWKLX8.uj.:user" |
| 912 |
auth-access: |
| 913 |
- "backup-script:backups:rw" |
| 914 |
auth-tokens: |
| 915 |
- "phil:tk_3gd7d2yftt4b8ixyfe9mnmro88o76:My personal token" |
| 916 |
``` |
| 917 |
|
| 918 |
=== "Config via env variables" |
| 919 |
``` yaml |
| 920 |
NTFY_AUTH_FILE='/var/lib/ntfy/user.db' |
| 921 |
NTFY_AUTH_DEFAULT_ACCESS='deny-all' |
| 922 |
NTFY_AUTH_USERS='phil:$2a$10$YLiO8U21sX1uhZamTLJXHuxgVC0Z/GKISibrKCLohPgtG7yIxSk4C:admin,backup-script:$2a$10$/ehiQt.w7lhTmHXq.RNsOOkIwiPPeWFIzWYO3DRxNixnWKLX8.uj.:user' |
| 923 |
NTFY_AUTH_ACCESS='backup-script:backups:rw' |
| 924 |
NTFY_AUTH_TOKENS='phil:tk_3gd7d2yftt4b8ixyfe9mnmro88o76:My personal token' |
| 925 |
``` |
| 926 |
|
| 927 |
Once you've done that, you can publish and subscribe using [Basic Auth](https://en.wikipedia.org/wiki/Basic_access_authentication) |
| 928 |
with the given username/password. Be sure to use HTTPS to avoid eavesdropping and exposing your password. |
| 929 |
|
| 930 |
Here's a simple example (using the credentials of the `phil` user): |
| 931 |
|
| 932 |
=== "Command line (curl)" |
| 933 |
``` |
| 934 |
curl \ |
| 935 |
-u phil:mypass \ |
| 936 |
-d "Look ma, with auth" \ |
| 937 |
https://ntfy.example.com/mysecrets |
| 938 |
``` |
| 939 |
|
| 940 |
=== "ntfy CLI" |
| 941 |
``` |
| 942 |
ntfy publish \ |
| 943 |
-u phil:mypass \ |
| 944 |
ntfy.example.com/mysecrets \ |
| 945 |
"Look ma, with auth" |
| 946 |
``` |
| 947 |
|
| 948 |
=== "HTTP" |
| 949 |
``` http |
| 950 |
POST /mysecrets HTTP/1.1 |
| 951 |
Host: ntfy.example.com |
| 952 |
Authorization: Basic cGhpbDpteXBhc3M= |
| 953 |
|
| 954 |
Look ma, with auth |
| 955 |
``` |
| 956 |
|
| 957 |
=== "JavaScript" |
| 958 |
``` javascript |
| 959 |
fetch('https://ntfy.example.com/mysecrets', { |
| 960 |
method: 'POST', // PUT works too |
| 961 |
body: 'Look ma, with auth', |
| 962 |
headers: { |
| 963 |
'Authorization': 'Basic cGhpbDpteXBhc3M=' |
| 964 |
} |
| 965 |
}) |
| 966 |
``` |
| 967 |
|
| 968 |
=== "Go" |
| 969 |
``` go |
| 970 |
req, _ := http.NewRequest("POST", "https://ntfy.example.com/mysecrets", |
| 971 |
strings.NewReader("Look ma, with auth")) |
| 972 |
req.Header.Set("Authorization", "Basic cGhpbDpteXBhc3M=") |
| 973 |
http.DefaultClient.Do(req) |
| 974 |
``` |
| 975 |
|
| 976 |
=== "Python" |
| 977 |
``` python |
| 978 |
requests.post("https://ntfy.example.com/mysecrets", |
| 979 |
data="Look ma, with auth", |
| 980 |
headers={ |
| 981 |
"Authorization": "Basic cGhpbDpteXBhc3M=" |
| 982 |
}) |
| 983 |
``` |
| 984 |
|
| 985 |
=== "PHP" |
| 986 |
``` php-inline |
| 987 |
file_get_contents('https://ntfy.example.com/mysecrets', false, stream_context_create([ |
| 988 |
'http' => [ |
| 989 |
'method' => 'POST', // PUT also works |
| 990 |
'header' => |
| 991 |
'Content-Type: text/plain\r\n' . |
| 992 |
'Authorization: Basic cGhpbDpteXBhc3M=', |
| 993 |
'content' => 'Look ma, with auth' |
| 994 |
] |
| 995 |
])); |
| 996 |
``` |
| 997 |
|
| 998 |
### Example: UnifiedPush |
| 999 |
[UnifiedPush](https://unifiedpush.org) requires that the [application server](https://unifiedpush.org/developers/spec/definitions/#application-server) (e.g. Synapse, Fediverse Server, …) |
| 1000 |
has anonymous write access to the [topic](https://unifiedpush.org/developers/spec/definitions/#endpoint) used for push messages. |
| 1001 |
The topic names used by UnifiedPush all start with the `up*` prefix. Please refer to the |
| 1002 |
**[UnifiedPush documentation](https://unifiedpush.org/users/distributors/ntfy/#limit-access-to-some-users-acl)** for more details. |
| 1003 |
|
| 1004 |
To enable support for UnifiedPush for private servers (i.e. `auth-default-access: "deny-all"`), you should either |
| 1005 |
allow anonymous write access for the entire prefix or explicitly per topic: |
| 1006 |
|
| 1007 |
=== "Prefix" |
| 1008 |
``` |
| 1009 |
$ ntfy access '*' 'up*' write-only |
| 1010 |
``` |
| 1011 |
|
| 1012 |
=== "Explicitly" |
| 1013 |
``` |
| 1014 |
$ ntfy access '*' upYzMtZGZiYTY5 write-only |
| 1015 |
``` |
| 1016 |
|
| 1017 |
## E-mail notifications |
| 1018 |
To allow forwarding messages via e-mail, you can configure an **SMTP server for outgoing messages**. Once configured, |
| 1019 |
you can set the `X-Email` header to [send messages via e-mail](publish.md#e-mail-notifications) (e.g. |
| 1020 |
`curl -d "hi there" -H "X-Email: [email protected]" ntfy.sh/mytopic`). |
| 1021 |
|
| 1022 |
!!! info |
| 1023 |
On ntfy.sh, anonymous email sending was disabled due to abuse. To use the email notification feature, |
| 1024 |
you must verify your email in the web app's [Account section](https://ntfy.sh/account). |
| 1025 |
|
| 1026 |
As of today, only SMTP servers with PLAIN auth and STARTLS are supported. To enable e-mail sending, you must set the |
| 1027 |
following settings: |
| 1028 |
|
| 1029 |
* `base-url` is the root URL for the ntfy server; this is needed for e-mail footer |
| 1030 |
* `smtp-sender-addr` is the hostname:port of the SMTP server |
| 1031 |
* `smtp-sender-user` and `smtp-sender-pass` are the username and password of the SMTP user |
| 1032 |
* `smtp-sender-from` is the e-mail address of the sender |
| 1033 |
* `smtp-sender-verify` is a flag that forces email recipient verification when enabled. If set to true, |
| 1034 |
only verified email recipients can be used in the `X-Email` header. |
| 1035 |
|
| 1036 |
Here's an example config using [Amazon SES](https://aws.amazon.com/ses/) for outgoing mail (this is how it is |
| 1037 |
configured for `ntfy.sh`): |
| 1038 |
|
| 1039 |
=== "/etc/ntfy/server.yml" |
| 1040 |
``` yaml |
| 1041 |
base-url: "https://ntfy.sh" |
| 1042 |
smtp-sender-addr: "email-smtp.us-east-2.amazonaws.com:587" |
| 1043 |
smtp-sender-user: "AKIDEADBEEFAFFE12345" |
| 1044 |
smtp-sender-pass: "Abd13Kf+sfAk2DzifjafldkThisIsNotARealKeyOMG." |
| 1045 |
smtp-sender-from: "[email protected]" |
| 1046 |
smtp-sender-verify: true |
| 1047 |
``` |
| 1048 |
|
| 1049 |
By default, any user (including anonymous users) can send email notifications to any address. To require email |
| 1050 |
address verification, set `smtp-sender-verify` to `true`. When enabled, anonymous users cannot send emails, and |
| 1051 |
authenticated users can only send to *literal* email addresses they have verified in their account settings. |
| 1052 |
|
| 1053 |
Regardless of this setting, a logged-in user can pass `yes`/`true`/`1` as the `X-Email` value to send to their primary |
| 1054 |
verified address (falling back to their first verified address if no primary is designated). `smtp-sender-verify` only |
| 1055 |
governs whether arbitrary literal addresses are allowed. |
| 1056 |
|
| 1057 |
Please also refer to the [rate limiting](#rate-limiting) settings below, specifically `visitor-email-limit-burst` |
| 1058 |
and `visitor-email-limit-burst`. Setting these conservatively is necessary to avoid abuse. |
| 1059 |
|
| 1060 |
## E-mail publishing |
| 1061 |
To allow publishing messages via e-mail, ntfy can run a lightweight **SMTP server for incoming messages**. Once configured, |
| 1062 |
users can [send emails to a topic e-mail address](publish.md#e-mail-publishing) (e.g. `[email protected]` or |
| 1063 |
`[email protected]`) to publish messages to a topic. This is useful for e-mail based integrations such as for |
| 1064 |
statuspage.io (though these days most services also support webhooks and HTTP calls). |
| 1065 |
|
| 1066 |
To configure the SMTP server, you must at least set `smtp-server-listen` and `smtp-server-domain`: |
| 1067 |
|
| 1068 |
* `smtp-server-listen` defines the IP address and port the SMTP server will listen on, e.g. `:25` or `1.2.3.4:25` |
| 1069 |
* `smtp-server-domain` is the e-mail domain, e.g. `ntfy.sh` (must be identical to MX record, see below) |
| 1070 |
* `smtp-server-addr-prefix` is an optional prefix for the e-mail addresses to prevent spam. If set to `ntfy-`, for instance, |
| 1071 |
only e-mails to `[email protected]` will be accepted. If this is not set, all emails to `[email protected]` will be |
| 1072 |
accepted (which may obviously be a spam problem). |
| 1073 |
|
| 1074 |
Here's an example config (this is how it is configured for `ntfy.sh`): |
| 1075 |
|
| 1076 |
=== "/etc/ntfy/server.yml" |
| 1077 |
``` yaml |
| 1078 |
smtp-server-listen: ":25" |
| 1079 |
smtp-server-domain: "ntfy.sh" |
| 1080 |
smtp-server-addr-prefix: "ntfy-" |
| 1081 |
``` |
| 1082 |
|
| 1083 |
In addition to configuring the ntfy server, you have to create two DNS records (an [MX record](https://en.wikipedia.org/wiki/MX_record) |
| 1084 |
and a corresponding A record), so incoming mail will find its way to your server. Here's an example of how `ntfy.sh` is |
| 1085 |
configured (in [Amazon Route 53](https://aws.amazon.com/route53/)): |
| 1086 |
|
| 1087 |
<figure markdown> |
| 1088 |
{ width=600 } |
| 1089 |
<figcaption>DNS records for incoming mail</figcaption> |
| 1090 |
</figure> |
| 1091 |
|
| 1092 |
You can check if everything is working correctly by sending an email as raw SMTP via `nc`. Create a text file, e.g. |
| 1093 |
`email.txt` |
| 1094 |
|
| 1095 |
``` |
| 1096 |
EHLO example.com |
| 1097 |
MAIL FROM: [email protected] |
| 1098 |
RCPT TO: [email protected] |
| 1099 |
DATA |
| 1100 |
Subject: Email for you |
| 1101 |
Content-Type: text/plain; charset="UTF-8" |
| 1102 |
|
| 1103 |
Hello from 🇩🇪 |
| 1104 |
. |
| 1105 |
``` |
| 1106 |
|
| 1107 |
And then send the mail via `nc` like this. If you see any lines starting with `451`, those are errors from the |
| 1108 |
ntfy server. Read them carefully. |
| 1109 |
|
| 1110 |
``` |
| 1111 |
$ cat email.txt | nc -N ntfy.sh 25 |
| 1112 |
220 ntfy.sh ESMTP Service Ready |
| 1113 |
250-Hello example.com |
| 1114 |
... |
| 1115 |
250 2.0.0 Roger, accepting mail from <[email protected]> |
| 1116 |
250 2.0.0 I'll make sure <[email protected]> gets this |
| 1117 |
``` |
| 1118 |
|
| 1119 |
As for the DNS setup, be sure to verify that `dig MX` and `dig A` are returning results similar to this: |
| 1120 |
|
| 1121 |
``` |
| 1122 |
$ dig MX ntfy.sh +short |
| 1123 |
10 mx1.ntfy.sh. |
| 1124 |
$ dig A mx1.ntfy.sh +short |
| 1125 |
3.139.215.220 |
| 1126 |
``` |
| 1127 |
|
| 1128 |
### Local-only email |
| 1129 |
If you want to send emails from an internal service on the same network as your ntfy instance, you do not need to |
| 1130 |
worry about DNS records at all. Define a port for the SMTP server and pick an SMTP server domain (can be |
| 1131 |
anything). |
| 1132 |
|
| 1133 |
=== "/etc/ntfy/server.yml" |
| 1134 |
``` yaml |
| 1135 |
smtp-server-listen: ":25" |
| 1136 |
smtp-server-domain: "example.com" |
| 1137 |
smtp-server-addr-prefix: "ntfy-" # optional |
| 1138 |
``` |
| 1139 |
|
| 1140 |
Then, in the email settings of your internal service, set the SMTP server address to the IP address of your |
| 1141 |
ntfy instance. Set the port to the value you defined in `smtp-server-listen`. Leave any username and password |
| 1142 |
fields empty. In the "From" address, pick anything (e.g., "[email protected]"); the value doesn't matter. |
| 1143 |
In the "To" address, put in an email address that follows this pattern: `[topic]@[smtp-server-domain]` (or |
| 1144 |
`[smtp-server-addr-prefix][topic]@[smtp-server-domain]` if you set `smtp-server-addr-prefix`). |
| 1145 |
|
| 1146 |
So if you used `example.com` as the SMTP server domain, and you want to send a message to the `email-alerts` |
| 1147 |
topic, set the "To" address to `[email protected]`. If the topic has access restrictions, you will need |
| 1148 |
to include an access token in the "To" address, such as `[email protected]`. |
| 1149 |
|
| 1150 |
If the internal service lets you use define an email "Subject", it will become the title of the notification. |
| 1151 |
The body of the email will become the message of the notification. |
| 1152 |
|
| 1153 |
## Behind a proxy (TLS, etc.) |
| 1154 |
!!! warning |
| 1155 |
If you are running ntfy behind a proxy, you must set the `behind-proxy` flag. Otherwise, all visitors are |
| 1156 |
[rate limited](#rate-limiting) as if they are one. |
| 1157 |
|
| 1158 |
It may be desirable to run ntfy behind a proxy (e.g. nginx, HAproxy or Apache), so you can provide TLS certificates |
| 1159 |
using Let's Encrypt using certbot, or simply because you'd like to share the ports (80/443) with other services. |
| 1160 |
Whatever your reasons may be, there are a few things to consider. |
| 1161 |
|
| 1162 |
### IP-based rate limiting |
| 1163 |
If you are running ntfy behind a proxy, you should set the `behind-proxy` flag. This will instruct the |
| 1164 |
[rate limiting](#rate-limiting) logic to use the header configured in `proxy-forwarded-header` (default is `X-Forwarded-For`) |
| 1165 |
as the primary identifier for a visitor, as opposed to the remote IP address. |
| 1166 |
|
| 1167 |
If the `behind-proxy` flag is not set, all visitors will be counted as one, because from the perspective of the |
| 1168 |
ntfy server, they all share the proxy's IP address. |
| 1169 |
|
| 1170 |
Relevant flags to consider: |
| 1171 |
|
| 1172 |
* `behind-proxy` makes it so that the real visitor IP address is extracted from the header defined in `proxy-forwarded-header`. |
| 1173 |
Without this, the remote address of the incoming connection is used (default: `false`). |
| 1174 |
* `proxy-forwarded-header` is the header to use to identify visitors (default: `X-Forwarded-For`). It may be a single IP address (e.g. `1.2.3.4`), |
| 1175 |
a comma-separated list of IP addresses (e.g. `1.2.3.4, 5.6.7.8`), or an [RFC 7239](https://datatracker.ietf.org/doc/html/rfc7239)-style |
| 1176 |
header (e.g. `for=1.2.3.4;by=proxy.example.com, for=5.6.7.8`). |
| 1177 |
* `proxy-trusted-hosts` is a comma-separated list of IP addresses, hosts or CIDRs that are removed from the forwarded header |
| 1178 |
to determine the real IP address. This is only useful if there are multiple proxies involved that add themselves to |
| 1179 |
the forwarded header (default: empty). |
| 1180 |
* `visitor-prefix-bits-ipv4` is the number of bits of the IPv4 address to use for rate limiting (default is `32`, which is the entire |
| 1181 |
IP address). In IPv4 environments, by default, a visitor's **full IPv4 address** is used as-is for rate limiting. This means that |
| 1182 |
if someone publishes messages from multiple IP addresses, they will be counted as separate visitors. You can adjust this by setting the `visitor-prefix-bits-ipv4` config option. To group visitors in a /24 subnet and count them as one, for instance, |
| 1183 |
set it to `24`. In that case, `1.2.3.4` and `1.2.3.99` are treated as the same visitor. |
| 1184 |
* `visitor-prefix-bits-ipv6` is the number of bits of the IPv6 address to use for rate limiting (default is `64`, which is a /64 subnet). |
| 1185 |
In IPv6 environments, by default, a visitor's IP address is **truncated to the /64 subnet**, meaning that `2001:db8:25:86:1::1` and |
| 1186 |
`2001:db8:25:86:2::1` are treated as the same visitor. Use the `visitor-prefix-bits-ipv6` config option to adjust this behavior. |
| 1187 |
See [IPv6 considerations](#ipv6-considerations) for more details. |
| 1188 |
|
| 1189 |
=== "/etc/ntfy/server.yml (behind a proxy)" |
| 1190 |
``` yaml |
| 1191 |
# Tell ntfy to use "X-Forwarded-For" header to identify visitors for rate limiting |
| 1192 |
# |
| 1193 |
# Example: If "X-Forwarded-For: 9.9.9.9, 1.2.3.4" is set, |
| 1194 |
# the visitor IP will be 1.2.3.4 (right-most address). |
| 1195 |
# |
| 1196 |
behind-proxy: true |
| 1197 |
``` |
| 1198 |
|
| 1199 |
=== "/etc/ntfy/server.yml (X-Client-IP header)" |
| 1200 |
``` yaml |
| 1201 |
# Tell ntfy to use "X-Client-IP" header to identify visitors for rate limiting |
| 1202 |
# |
| 1203 |
# Example: If "X-Client-IP: 9.9.9.9" is set, |
| 1204 |
# the visitor IP will be 9.9.9.9. |
| 1205 |
# |
| 1206 |
behind-proxy: true |
| 1207 |
proxy-forwarded-header: "X-Client-IP" |
| 1208 |
``` |
| 1209 |
|
| 1210 |
=== "/etc/ntfy/server.yml (Forwarded header)" |
| 1211 |
``` yaml |
| 1212 |
# Tell ntfy to use "Forwarded" header (RFC 7239) to identify visitors for rate limiting |
| 1213 |
# |
| 1214 |
# Example: If "Forwarded: for=1.2.3.4;by=proxy.example.com, for=9.9.9.9" is set, |
| 1215 |
# the visitor IP will be 9.9.9.9. |
| 1216 |
# |
| 1217 |
behind-proxy: true |
| 1218 |
proxy-forwarded-header: "Forwarded" |
| 1219 |
``` |
| 1220 |
|
| 1221 |
=== "/etc/ntfy/server.yml (multiple proxies)" |
| 1222 |
``` yaml |
| 1223 |
# Tell ntfy to use "X-Forwarded-For" header to identify visitors for rate limiting, |
| 1224 |
# and to strip the IP addresses of the proxies 1.2.3.4 and 1.2.3.5 |
| 1225 |
# |
| 1226 |
# Example: If "X-Forwarded-For: 9.9.9.9, 1.2.3.4" is set, |
| 1227 |
# the visitor IP will be 9.9.9.9 (right-most unknown address). |
| 1228 |
# |
| 1229 |
behind-proxy: true |
| 1230 |
proxy-trusted-hosts: "1.2.3.0/24, 1.2.2.2, 2001:db8::/64" |
| 1231 |
``` |
| 1232 |
|
| 1233 |
=== "/etc/ntfy/server.yml (adjusted IPv4/IPv6 prefixes proxies)" |
| 1234 |
``` yaml |
| 1235 |
# Tell ntfy to treat visitors as being in a /24 subnet (IPv4) or /48 subnet (IPv6) |
| 1236 |
# as one visitor, so that they are counted as one for rate limiting. |
| 1237 |
# |
| 1238 |
# Example 1: If 1.2.3.4 and 1.2.3.5 publish a message, the visitor 1.2.3.0 will have |
| 1239 |
# used 2 messages. |
| 1240 |
# Example 2: If 2001:db8:2500:1::1 and 2001:db8:2500:2::1 publish a message, the visitor |
| 1241 |
# 2001:db8:2500:: will have used 2 messages. |
| 1242 |
# |
| 1243 |
visitor-prefix-bits-ipv4: 24 |
| 1244 |
visitor-prefix-bits-ipv6: 48 |
| 1245 |
``` |
| 1246 |
|
| 1247 |
### TLS/SSL |
| 1248 |
ntfy supports HTTPS/TLS by setting the `listen-https` [config option](#config-options). However, if you |
| 1249 |
are behind a proxy, it is recommended that TLS/SSL termination is done by the proxy itself (see below). |
| 1250 |
|
| 1251 |
I highly recommend using [certbot](https://certbot.eff.org/). I use it with the [dns-route53 plugin](https://certbot-dns-route53.readthedocs.io/en/stable/), |
| 1252 |
which lets you use [AWS Route 53](https://aws.amazon.com/route53/) as the challenge. That's much easier than using the |
| 1253 |
HTTP challenge. I've found [this guide](https://nandovieira.com/using-lets-encrypt-in-development-with-nginx-and-aws-route53) to |
| 1254 |
be incredibly helpful. |
| 1255 |
|
| 1256 |
### nginx/Apache2/caddy |
| 1257 |
For your convenience, here's a working config that'll help configure things behind a proxy. Be sure to **enable WebSockets** |
| 1258 |
by forwarding the `Connection` and `Upgrade` headers accordingly. |
| 1259 |
|
| 1260 |
In this example, ntfy runs on `:2586` and we proxy traffic to it. We also redirect HTTP to HTTPS for GET requests against a topic |
| 1261 |
or the root domain: |
| 1262 |
|
| 1263 |
=== "nginx (convenient)" |
| 1264 |
``` |
| 1265 |
# /etc/nginx/sites-*/ntfy |
| 1266 |
# |
| 1267 |
# This config allows insecure HTTP POST/PUT requests against topics to allow a short curl syntax (without -L |
| 1268 |
# and "https://" prefix). It also disables output buffering, which has worked well for the ntfy.sh server. |
| 1269 |
# |
| 1270 |
# This is pretty much how ntfy.sh is configured. To see the exact configuration, |
| 1271 |
# see https://github.com/binwiederhier/ntfy-ansible/ |
| 1272 |
|
| 1273 |
server { |
| 1274 |
listen 80; |
| 1275 |
server_name ntfy.sh; |
| 1276 |
|
| 1277 |
location / { |
| 1278 |
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want |
| 1279 |
# it to work with curl without the annoying https:// prefix |
| 1280 |
set $redirect_https ""; |
| 1281 |
if ($request_method = GET) { |
| 1282 |
set $redirect_https "yes"; |
| 1283 |
} |
| 1284 |
if ($request_uri ~* "^/([-_a-z0-9]{0,64}$|docs/|static/)") { |
| 1285 |
set $redirect_https "${redirect_https}yes"; |
| 1286 |
} |
| 1287 |
if ($redirect_https = "yesyes") { |
| 1288 |
return 302 https://$http_host$request_uri$is_args$query_string; |
| 1289 |
} |
| 1290 |
|
| 1291 |
proxy_pass http://127.0.0.1:2586; |
| 1292 |
proxy_http_version 1.1; |
| 1293 |
|
| 1294 |
proxy_buffering off; |
| 1295 |
proxy_request_buffering off; |
| 1296 |
proxy_redirect off; |
| 1297 |
|
| 1298 |
proxy_set_header Host $http_host; |
| 1299 |
proxy_set_header Upgrade $http_upgrade; |
| 1300 |
proxy_set_header Connection "upgrade"; |
| 1301 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 1302 |
|
| 1303 |
proxy_connect_timeout 3m; |
| 1304 |
proxy_send_timeout 3m; |
| 1305 |
proxy_read_timeout 3m; |
| 1306 |
|
| 1307 |
client_max_body_size 0; # Stream request body to backend |
| 1308 |
} |
| 1309 |
} |
| 1310 |
|
| 1311 |
server { |
| 1312 |
listen 443 ssl http2; |
| 1313 |
server_name ntfy.sh; |
| 1314 |
|
| 1315 |
# See https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=intermediate&openssl=1.1.1k&hsts=false&ocsp=false&guideline=5.6 |
| 1316 |
ssl_session_timeout 1d; |
| 1317 |
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions |
| 1318 |
ssl_session_tickets off; |
| 1319 |
ssl_protocols TLSv1.2 TLSv1.3; |
| 1320 |
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; |
| 1321 |
ssl_prefer_server_ciphers off; |
| 1322 |
|
| 1323 |
ssl_certificate /etc/letsencrypt/live/ntfy.sh/fullchain.pem; |
| 1324 |
ssl_certificate_key /etc/letsencrypt/live/ntfy.sh/privkey.pem; |
| 1325 |
|
| 1326 |
location / { |
| 1327 |
proxy_pass http://127.0.0.1:2586; |
| 1328 |
proxy_http_version 1.1; |
| 1329 |
|
| 1330 |
proxy_buffering off; |
| 1331 |
proxy_request_buffering off; |
| 1332 |
proxy_redirect off; |
| 1333 |
|
| 1334 |
proxy_set_header Host $http_host; |
| 1335 |
proxy_set_header Upgrade $http_upgrade; |
| 1336 |
proxy_set_header Connection "upgrade"; |
| 1337 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 1338 |
|
| 1339 |
proxy_connect_timeout 3m; |
| 1340 |
proxy_send_timeout 3m; |
| 1341 |
proxy_read_timeout 3m; |
| 1342 |
|
| 1343 |
client_max_body_size 0; # Stream request body to backend |
| 1344 |
} |
| 1345 |
} |
| 1346 |
``` |
| 1347 |
|
| 1348 |
=== "nginx (more secure)" |
| 1349 |
``` |
| 1350 |
# /etc/nginx/sites-*/ntfy |
| 1351 |
# |
| 1352 |
# This config requires the use of the -L flag in curl to redirect to HTTPS, and it keeps nginx output buffering |
| 1353 |
# enabled. While recommended, I have had issues with that in the past. |
| 1354 |
|
| 1355 |
server { |
| 1356 |
listen 80; |
| 1357 |
server_name ntfy.sh; |
| 1358 |
|
| 1359 |
location / { |
| 1360 |
return 302 https://$http_host$request_uri$is_args$query_string; |
| 1361 |
|
| 1362 |
proxy_pass http://127.0.0.1:2586; |
| 1363 |
proxy_http_version 1.1; |
| 1364 |
|
| 1365 |
proxy_set_header Host $http_host; |
| 1366 |
proxy_set_header Upgrade $http_upgrade; |
| 1367 |
proxy_set_header Connection "upgrade"; |
| 1368 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 1369 |
|
| 1370 |
proxy_connect_timeout 3m; |
| 1371 |
proxy_send_timeout 3m; |
| 1372 |
proxy_read_timeout 3m; |
| 1373 |
|
| 1374 |
client_max_body_size 0; # Stream request body to backend |
| 1375 |
} |
| 1376 |
} |
| 1377 |
|
| 1378 |
server { |
| 1379 |
listen 443 ssl http2; |
| 1380 |
server_name ntfy.sh; |
| 1381 |
|
| 1382 |
# See https://ssl-config.mozilla.org/#server=nginx&version=1.18.0&config=intermediate&openssl=1.1.1k&hsts=false&ocsp=false&guideline=5.6 |
| 1383 |
ssl_session_timeout 1d; |
| 1384 |
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions |
| 1385 |
ssl_session_tickets off; |
| 1386 |
ssl_protocols TLSv1.2 TLSv1.3; |
| 1387 |
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; |
| 1388 |
ssl_prefer_server_ciphers off; |
| 1389 |
|
| 1390 |
ssl_certificate /etc/letsencrypt/live/ntfy.sh/fullchain.pem; |
| 1391 |
ssl_certificate_key /etc/letsencrypt/live/ntfy.sh/privkey.pem; |
| 1392 |
|
| 1393 |
location / { |
| 1394 |
proxy_pass http://127.0.0.1:2586; |
| 1395 |
proxy_http_version 1.1; |
| 1396 |
|
| 1397 |
proxy_set_header Host $http_host; |
| 1398 |
proxy_set_header Upgrade $http_upgrade; |
| 1399 |
proxy_set_header Connection "upgrade"; |
| 1400 |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 1401 |
|
| 1402 |
proxy_connect_timeout 3m; |
| 1403 |
proxy_send_timeout 3m; |
| 1404 |
proxy_read_timeout 3m; |
| 1405 |
|
| 1406 |
client_max_body_size 0; # Stream request body to backend |
| 1407 |
} |
| 1408 |
} |
| 1409 |
``` |
| 1410 |
|
| 1411 |
=== "Apache >= 2.4.47" |
| 1412 |
``` |
| 1413 |
# /etc/apache2/sites-*/ntfy.conf |
| 1414 |
|
| 1415 |
<VirtualHost *:80> |
| 1416 |
ServerName ntfy.sh |
| 1417 |
|
| 1418 |
# Proxy connections to ntfy (requires "a2enmod proxy proxy_http") |
| 1419 |
# Use mod_proxy_http for websocket upgrade ('upgrade=websocket'), which requires Apache (httpd) >= 2.4.47. |
| 1420 |
ProxyPass / http://127.0.0.1:2586/ upgrade=websocket |
| 1421 |
ProxyPassReverse / http://127.0.0.1:2586/ |
| 1422 |
|
| 1423 |
SetEnv proxy-nokeepalive 1 |
| 1424 |
SetEnv proxy-sendchunked 1 |
| 1425 |
|
| 1426 |
# Higher than the max message size of 4096 bytes |
| 1427 |
LimitRequestBody 102400 |
| 1428 |
|
| 1429 |
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want |
| 1430 |
# it to work with curl without the annoying https:// prefix (requires "a2enmod alias") |
| 1431 |
<If "%{REQUEST_METHOD} == 'GET'"> |
| 1432 |
RedirectMatch permanent "^/([-_A-Za-z0-9]{0,64})$" "https://%{SERVER_NAME}/$1" |
| 1433 |
</If> |
| 1434 |
|
| 1435 |
</VirtualHost> |
| 1436 |
|
| 1437 |
<VirtualHost *:443> |
| 1438 |
ServerName ntfy.sh |
| 1439 |
|
| 1440 |
SSLEngine on |
| 1441 |
SSLCertificateFile /etc/letsencrypt/live/ntfy.sh/fullchain.pem |
| 1442 |
SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem |
| 1443 |
Include /etc/letsencrypt/options-ssl-apache.conf |
| 1444 |
|
| 1445 |
# Proxy connections to ntfy (requires "a2enmod proxy proxy_http") |
| 1446 |
# Use mod_proxy_http for websocket upgrade ('upgrade=websocket'), which requires Apache (httpd) >= 2.4.47. |
| 1447 |
ProxyPass / http://127.0.0.1:2586/ upgrade=websocket |
| 1448 |
ProxyPassReverse / http://127.0.0.1:2586/ |
| 1449 |
|
| 1450 |
SetEnv proxy-nokeepalive 1 |
| 1451 |
SetEnv proxy-sendchunked 1 |
| 1452 |
|
| 1453 |
# Higher than the max message size of 4096 bytes |
| 1454 |
LimitRequestBody 102400 |
| 1455 |
|
| 1456 |
</VirtualHost> |
| 1457 |
``` |
| 1458 |
|
| 1459 |
=== "Apache < 2.4.47" |
| 1460 |
``` |
| 1461 |
# /etc/apache2/sites-*/ntfy.conf |
| 1462 |
|
| 1463 |
<VirtualHost *:80> |
| 1464 |
ServerName ntfy.sh |
| 1465 |
|
| 1466 |
# Proxy connections to ntfy (requires "a2enmod proxy") |
| 1467 |
ProxyPass / http://127.0.0.1:2586/ |
| 1468 |
ProxyPassReverse / http://127.0.0.1:2586/ |
| 1469 |
|
| 1470 |
# Enable mod_rewrite (requires "a2enmod rewrite") |
| 1471 |
RewriteEngine on |
| 1472 |
# WebSockets support (requires "a2enmod proxy_wstunnel") |
| 1473 |
# mod_proxy_wstunnel is deprecated as of Apache (httpd) 2.4.47. It also uses more resources since it relies on mod_rewrite. |
| 1474 |
RewriteCond %{HTTP:Upgrade} websocket [NC] |
| 1475 |
RewriteCond %{HTTP:Connection} upgrade [NC] |
| 1476 |
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L] |
| 1477 |
|
| 1478 |
SetEnv proxy-nokeepalive 1 |
| 1479 |
SetEnv proxy-sendchunked 1 |
| 1480 |
|
| 1481 |
# Higher than the max message size of 4096 bytes |
| 1482 |
LimitRequestBody 102400 |
| 1483 |
|
| 1484 |
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want |
| 1485 |
# it to work with curl without the annoying https:// prefix (requires "a2enmod alias") |
| 1486 |
<If "%{REQUEST_METHOD} == 'GET'"> |
| 1487 |
RedirectMatch permanent "^/([-_A-Za-z0-9]{0,64})$" "https://%{SERVER_NAME}/$1" |
| 1488 |
</If> |
| 1489 |
|
| 1490 |
</VirtualHost> |
| 1491 |
|
| 1492 |
<VirtualHost *:443> |
| 1493 |
ServerName ntfy.sh |
| 1494 |
|
| 1495 |
SSLEngine on |
| 1496 |
SSLCertificateFile /etc/letsencrypt/live/ntfy.sh/fullchain.pem |
| 1497 |
SSLCertificateKeyFile /etc/letsencrypt/live/ntfy.sh/privkey.pem |
| 1498 |
Include /etc/letsencrypt/options-ssl-apache.conf |
| 1499 |
|
| 1500 |
# Proxy connections to ntfy (requires "a2enmod proxy") |
| 1501 |
ProxyPass / http://127.0.0.1:2586/ |
| 1502 |
ProxyPassReverse / http://127.0.0.1:2586/ |
| 1503 |
|
| 1504 |
# Enable mod_rewrite (requires "a2enmod rewrite") |
| 1505 |
RewriteEngine on |
| 1506 |
# WebSockets support (requires "a2enmod proxy_wstunnel") |
| 1507 |
# mod_proxy_wstunnel is deprecated as of Apache (httpd) 2.4.47. It also uses more resources since it relies on mod_rewrite. |
| 1508 |
RewriteCond %{HTTP:Upgrade} websocket [NC] |
| 1509 |
RewriteCond %{HTTP:Connection} upgrade [NC] |
| 1510 |
RewriteRule ^/?(.*) "ws://127.0.0.1:2586/$1" [P,L] |
| 1511 |
|
| 1512 |
SetEnv proxy-nokeepalive 1 |
| 1513 |
SetEnv proxy-sendchunked 1 |
| 1514 |
|
| 1515 |
# Higher than the max message size of 4096 bytes |
| 1516 |
LimitRequestBody 102400 |
| 1517 |
|
| 1518 |
</VirtualHost> |
| 1519 |
``` |
| 1520 |
|
| 1521 |
=== "caddy" |
| 1522 |
``` |
| 1523 |
# Note that this config is most certainly incomplete. Please help out and let me know what's missing |
| 1524 |
# via the contact page (https://ntfy.sh/docs/contact/) or in a GitHub issue. |
| 1525 |
# Note: Caddy automatically handles both HTTP and WebSockets with reverse_proxy |
| 1526 |
|
| 1527 |
ntfy.sh, http://nfty.sh { |
| 1528 |
reverse_proxy 127.0.0.1:2586 |
| 1529 |
|
| 1530 |
# Redirect HTTP to HTTPS, but only for GET topic addresses, since we want |
| 1531 |
# it to work with curl without the annoying https:// prefix |
| 1532 |
@httpget { |
| 1533 |
protocol http |
| 1534 |
method GET |
| 1535 |
path_regexp ^/([-_a-z0-9]{0,64}$|docs/|static/) |
| 1536 |
} |
| 1537 |
redir @httpget https://{host}{uri} |
| 1538 |
} |
| 1539 |
``` |
| 1540 |
|
| 1541 |
=== "ferron" |
| 1542 |
``` kdl |
| 1543 |
// /etc/ferron.kdl |
| 1544 |
// Note that this config is most certainly incomplete. Please help out and let me know what's missing |
| 1545 |
// via the contact page (https://ntfy.sh/docs/contact/) or in a GitHub issue. |
| 1546 |
// Note: Ferron automatically handles both HTTP and WebSockets with proxy |
| 1547 |
|
| 1548 |
ntfy.sh { |
| 1549 |
auto_tls |
| 1550 |
auto_tls_letsencrypt_production |
| 1551 |
protocols "h1" "h2" "h3" |
| 1552 |
|
| 1553 |
proxy "http://127.0.0.1:2586" |
| 1554 |
|
| 1555 |
// Redirect HTTP to HTTPS, but only for GET topic addresses, since we want |
| 1556 |
// it to work with curl without the annoying https:// prefix |
| 1557 |
|
| 1558 |
no_redirect_to_https #true |
| 1559 |
|
| 1560 |
condition "is_get_topic" { |
| 1561 |
is_equal "{method}" "GET" |
| 1562 |
is_regex "{path}" "^/([-_a-z0-9]{0,64}$|docs/|static/)" |
| 1563 |
} |
| 1564 |
|
| 1565 |
if "is_get_topic" { |
| 1566 |
no_redirect_to_https #false |
| 1567 |
} |
| 1568 |
} |
| 1569 |
``` |
| 1570 |
|
| 1571 |
## Firebase (FCM) |
| 1572 |
!!! info |
| 1573 |
Using Firebase is **optional** and only works if you modify and [build your own Android .apk](develop.md#android-app). |
| 1574 |
For a self-hosted instance, it's easier to just not bother with FCM. |
| 1575 |
|
| 1576 |
[Firebase Cloud Messaging (FCM)](https://firebase.google.com/docs/cloud-messaging) is the Google approved way to send |
| 1577 |
push messages to Android devices. FCM is the only method that an Android app can receive messages without having to run a |
| 1578 |
[foreground service](https://developer.android.com/guide/components/foreground-services). |
| 1579 |
|
| 1580 |
For the main host [ntfy.sh](https://ntfy.sh), the [ntfy Android app](subscribe/phone.md) uses Firebase to send messages |
| 1581 |
to the device. For other hosts, instant delivery is used and FCM is not involved. |
| 1582 |
|
| 1583 |
To configure FCM for your self-hosted instance of the ntfy server, follow these steps: |
| 1584 |
|
| 1585 |
1. Sign up for a [Firebase account](https://console.firebase.google.com/) |
| 1586 |
2. Create a Firebase app and download the key file (e.g. `myapp-firebase-adminsdk-...json`) |
| 1587 |
3. Place the key file in `/etc/ntfy`, set the `firebase-key-file` in `server.yml` accordingly and restart the ntfy server |
| 1588 |
4. Build your own Android .apk following [these instructions](develop.md#android-app) |
| 1589 |
|
| 1590 |
Example: |
| 1591 |
``` |
| 1592 |
# If set, also publish messages to a Firebase Cloud Messaging (FCM) topic for your app. |
| 1593 |
# This is optional and only required to support Android apps (which don't allow background services anymore). |
| 1594 |
# |
| 1595 |
firebase-key-file: "/etc/ntfy/ntfy-sh-firebase-adminsdk-ahnce-9f4d6f14b5.json" |
| 1596 |
``` |
| 1597 |
|
| 1598 |
## iOS instant notifications |
| 1599 |
Unlike Android, iOS heavily restricts background processing, which sadly makes it impossible to implement instant |
| 1600 |
push notifications without a central server. |
| 1601 |
|
| 1602 |
To still support instant notifications on iOS through your self-hosted ntfy server, you have to forward so called `poll_request` |
| 1603 |
messages to the main ntfy.sh server (or any upstream server that's APNS/Firebase connected, if you build your own iOS app), |
| 1604 |
which will then forward it to Firebase/APNS. |
| 1605 |
|
| 1606 |
To configure it, simply set `upstream-base-url` like so: |
| 1607 |
|
| 1608 |
``` yaml |
| 1609 |
upstream-base-url: "https://ntfy.sh" |
| 1610 |
upstream-access-token: "..." # optional, only if rate limits exceeded, or upstream server protected |
| 1611 |
``` |
| 1612 |
|
| 1613 |
If set, all incoming messages will publish a poll request to the configured upstream server, containing |
| 1614 |
the message ID of the original message, instructing the iOS app to poll this server for the actual message contents. |
| 1615 |
|
| 1616 |
If `upstream-base-url` is not set, notifications will still eventually get to your device, but delivery can take hours, |
| 1617 |
depending on the state of the phone. If you are using your phone, it shouldn't take more than 20-30 minutes though. |
| 1618 |
|
| 1619 |
In case you're curious, here's an example of the entire flow: |
| 1620 |
|
| 1621 |
- In the iOS app, you subscribe to `https://ntfy.example.com/mytopic` |
| 1622 |
- The app subscribes to the Firebase topic `6de73be8dfb7d69e...` (the SHA256 of the topic URL) |
| 1623 |
- When you publish a message to `https://ntfy.example.com/mytopic`, your ntfy server will publish a |
| 1624 |
poll request to `https://ntfy.sh/6de73be8dfb7d69e...`. The request from your server to the upstream server |
| 1625 |
contains only the message ID (in the `X-Poll-ID` header), and the SHA256 checksum of the topic URL (as upstream topic). |
| 1626 |
- The ntfy.sh server publishes the poll request message to Firebase, which forwards it to APNS, which forwards it to your iOS device |
| 1627 |
- Your iOS device receives the poll request, and fetches the actual message from your server, and then displays it |
| 1628 |
|
| 1629 |
Here's an example of what the self-hosted server forwards to the upstream server. The request is equivalent to this curl: |
| 1630 |
|
| 1631 |
``` |
| 1632 |
curl -X POST -H "X-Poll-ID: s4PdJozxM8na" https://ntfy.sh/6de73be8dfb7d69e32fb2c00c23fe7adbd8b5504406e3068c273aa24cef4055b |
| 1633 |
{"id":"4HsClFEuCIcs","time":1654087955,"event":"poll_request","topic":"6de73be8dfb7d69e32fb2c00c23fe7adbd8b5504406e3068c273aa24cef4055b","message":"New message","poll_id":"s4PdJozxM8na"} |
| 1634 |
``` |
| 1635 |
|
| 1636 |
Note that the self-hosted server literally sends the message `New message` for every message, even if your message |
| 1637 |
may be `Some other message`. This is so that if iOS cannot talk to the self-hosted server (in time, or at all), |
| 1638 |
it'll show `New message` as a popup. |
| 1639 |
|
| 1640 |
## Web Push |
| 1641 |
[Web Push](https://developer.mozilla.org/en-US/docs/Web/API/Push_API) ([RFC8030](https://datatracker.ietf.org/doc/html/rfc8030)) |
| 1642 |
allows ntfy to receive push notifications, even when the ntfy web app (or even the browser, depending on the platform) is closed. |
| 1643 |
When enabled, the user can enable **background notifications** for their topics in the web app under Settings. Once enabled by the |
| 1644 |
user, ntfy will forward published messages to the push endpoint (browser-provided, e.g. fcm.googleapis.com), which will then |
| 1645 |
forward it to the browser. |
| 1646 |
|
| 1647 |
To configure Web Push, you need to generate and configure a [VAPID](https://datatracker.ietf.org/doc/html/draft-thomson-webpush-vapid) keypair (via `ntfy webpush keys`), |
| 1648 |
a database to keep track of the browser's subscriptions, and an admin email address (you): |
| 1649 |
|
| 1650 |
- `web-push-public-key` is the generated VAPID public key, e.g. AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890 |
| 1651 |
- `web-push-private-key` is the generated VAPID private key, e.g. AA2BB1234567890abcdefzxcvbnm1234567890 |
| 1652 |
- `web-push-file` is a database file to keep track of browser subscription endpoints, e.g. `/var/cache/ntfy/webpush.db` (not required if `database-url` is set) |
| 1653 |
- `web-push-email-address` is the admin email address send to the push provider, e.g. `[email protected]` |
| 1654 |
- `web-push-startup-queries` is an optional list of queries to run on startup` |
| 1655 |
- `web-push-expiry-warning-duration` defines the duration after which unused subscriptions are sent a warning (default is `55d`) |
| 1656 |
- `web-push-expiry-duration` defines the duration after which unused subscriptions will expire (default is `60d`) |
| 1657 |
|
| 1658 |
Alternatively, you can use PostgreSQL instead of SQLite by setting `database-url` |
| 1659 |
(see [PostgreSQL database](#postgresql)). |
| 1660 |
|
| 1661 |
Limitations: |
| 1662 |
|
| 1663 |
- Like foreground browser notifications, background push notifications require the web app to be served over HTTPS. A _valid_ |
| 1664 |
certificate is required, as service workers will not run on origins with untrusted certificates. |
| 1665 |
|
| 1666 |
- Web Push is only supported for the same server. You cannot use subscribe to web push on a topic on another server. This |
| 1667 |
is due to a limitation of the Push API, which doesn't allow multiple push servers for the same origin. |
| 1668 |
|
| 1669 |
To configure VAPID keys, first generate them: |
| 1670 |
|
| 1671 |
```sh |
| 1672 |
$ ntfy webpush keys |
| 1673 |
Web Push keys generated. |
| 1674 |
... |
| 1675 |
``` |
| 1676 |
|
| 1677 |
Then copy the generated values into your `server.yml` or use the corresponding environment variables or command line arguments: |
| 1678 |
|
| 1679 |
```yaml |
| 1680 |
web-push-public-key: AA1234BBCCddvveekaabcdfqwertyuiopasdfghjklzxcvbnm1234567890 |
| 1681 |
web-push-private-key: AA2BB1234567890abcdefzxcvbnm1234567890 |
| 1682 |
web-push-file: /var/cache/ntfy/webpush.db |
| 1683 |
web-push-email-address: [email protected] |
| 1684 |
``` |
| 1685 |
|
| 1686 |
The `web-push-file` is used to store the push subscriptions in a local SQLite database. Alternatively, if `database-url` |
| 1687 |
is set, subscriptions are stored in PostgreSQL and `web-push-file` is not required. Unused subscriptions will send out |
| 1688 |
a warning after 55 days, and will automatically expire after 60 days (default). If the gateway returns an error |
| 1689 |
(e.g. 410 Gone when a user has unsubscribed), subscriptions are also removed automatically. |
| 1690 |
|
| 1691 |
The web app refreshes subscriptions on start and regularly on an interval, but this file should be persisted across restarts. If the subscription |
| 1692 |
file is deleted or lost, any web apps that aren't open will not receive new web push notifications until you open then. |
| 1693 |
|
| 1694 |
Changing your public/private keypair is **not recommended**. Browsers only allow one server identity (public key) per origin, and |
| 1695 |
if you change them the clients will not be able to subscribe via web push until the user manually clears the notification permission. |
| 1696 |
|
| 1697 |
## Tiers |
| 1698 |
ntfy supports associating users to pre-defined tiers. Tiers can be used to grant users higher limits, such as |
| 1699 |
daily message limits, attachment size, or make it possible for users to reserve topics. If [payments are enabled](#payments), |
| 1700 |
tiers can be paid or unpaid, and users can upgrade/downgrade between them. If payments are disabled, then the only way |
| 1701 |
to switch between tiers is with the `ntfy user change-tier` command (see [users and roles](#users-and-roles)). |
| 1702 |
|
| 1703 |
By default, **newly created users have no tier**, and all usage limits are read from the `server.yml` config file. |
| 1704 |
Once a user is associated with a tier, some limits are overridden based on the tier. |
| 1705 |
|
| 1706 |
The `ntfy tier` command can be used to manage all available tiers. By default, there are no pre-defined tiers. |
| 1707 |
|
| 1708 |
**Example commands** (type `ntfy token --help` or `ntfy token COMMAND --help` for more details): |
| 1709 |
``` |
| 1710 |
ntfy tier add pro # Add tier with code "pro", using the defaults |
| 1711 |
ntfy tier change --name="Pro" pro # Update the name of an existing tier |
| 1712 |
ntfy tier del starter # Delete an existing tier |
| 1713 |
ntfy user change-tier phil pro # Switch user "phil" to tier "pro" |
| 1714 |
``` |
| 1715 |
|
| 1716 |
**Creating a tier (full example):** |
| 1717 |
``` |
| 1718 |
ntfy tier add \ |
| 1719 |
--name="Pro" \ |
| 1720 |
--message-limit=10000 \ |
| 1721 |
--message-expiry-duration=24h \ |
| 1722 |
--email-limit=50 \ |
| 1723 |
--call-limit=10 \ |
| 1724 |
--reservation-limit=10 \ |
| 1725 |
--attachment-file-size-limit=100M \ |
| 1726 |
--attachment-total-size-limit=1G \ |
| 1727 |
--attachment-expiry-duration=12h \ |
| 1728 |
--attachment-bandwidth-limit=5G \ |
| 1729 |
--stripe-price-id=price_123456 \ |
| 1730 |
pro |
| 1731 |
``` |
| 1732 |
|
| 1733 |
## Payments |
| 1734 |
ntfy supports paid [tiers](#tiers) via [Stripe](https://stripe.com/) as a payment provider. If payments are enabled, |
| 1735 |
users can register, login and switch plans in the web app. The web app will behave slightly differently if payments |
| 1736 |
are enabled (e.g. showing an upgrade banner, or "ntfy Pro" tags). |
| 1737 |
|
| 1738 |
!!! info |
| 1739 |
The ntfy payments integration is very tailored to ntfy.sh and Stripe. I do not intend to support arbitrary use |
| 1740 |
cases. |
| 1741 |
|
| 1742 |
To enable payments, sign up with [Stripe](https://stripe.com/), set the `stripe-secret-key` and `stripe-webhook-key` |
| 1743 |
config options: |
| 1744 |
|
| 1745 |
* `stripe-secret-key` is the key used for the Stripe API communication. Setting this values |
| 1746 |
enables payments in the ntfy web app (e.g. Upgrade dialog). See [API keys](https://dashboard.stripe.com/apikeys). |
| 1747 |
* `stripe-webhook-key` is the key required to validate the authenticity of incoming webhooks from Stripe. |
| 1748 |
Webhooks are essential to keep the local database in sync with the payment provider. See [Webhooks](https://dashboard.stripe.com/webhooks). |
| 1749 |
* `billing-contact` is an email address or website displayed in the "Upgrade tier" dialog to let people reach |
| 1750 |
out with billing questions. If unset, nothing will be displayed. |
| 1751 |
|
| 1752 |
In addition to setting these two options, you also need to define a [Stripe webhook](https://dashboard.stripe.com/webhooks) |
| 1753 |
for the `customer.subscription.updated` and `customer.subscription.deleted` event, which points |
| 1754 |
to `https://ntfy.example.com/v1/account/billing/webhook`. |
| 1755 |
|
| 1756 |
Here's an example: |
| 1757 |
|
| 1758 |
``` yaml |
| 1759 |
stripe-secret-key: "sk_test_ZmhzZGtmbGhkc2tqZmhzYcO2a2hmbGtnaHNkbGtnaGRsc2hnbG" |
| 1760 |
stripe-webhook-key: "whsec_ZnNkZnNIRExBSFNES0hBRFNmaHNka2ZsaGR" |
| 1761 |
billing-contact: "[email protected]" |
| 1762 |
``` |
| 1763 |
|
| 1764 |
## Phone calls |
| 1765 |
ntfy supports phone calls via [Twilio](https://www.twilio.com/) as a call provider. If phone calls are enabled, |
| 1766 |
users can verify and add a phone number, and then receive phone calls when publishing a message using the `X-Call` header. |
| 1767 |
See [publishing page](publish.md#phone-calls) for more details. |
| 1768 |
|
| 1769 |
To enable Twilio integration, sign up with [Twilio](https://www.twilio.com/), purchase a phone number (Toll free numbers |
| 1770 |
are the easiest), and then configure the following options: |
| 1771 |
|
| 1772 |
* `twilio-account` is the Twilio account SID, e.g. AC12345beefbeef67890beefbeef122586 |
| 1773 |
* `twilio-auth-token` is the Twilio auth token, e.g. affebeef258625862586258625862586 |
| 1774 |
* `twilio-phone-number` is the outgoing phone number you purchased, e.g. +18775132586 |
| 1775 |
* `twilio-verify-service` is the Twilio Verify service SID, e.g. VA12345beefbeef67890beefbeef122586 |
| 1776 |
* `twilio-call-format` is the custom Twilio markup ([TwiML](https://www.twilio.com/docs/voice/twiml)) to use for phone calls (optional) |
| 1777 |
|
| 1778 |
After you have configured phone calls, create a [tier](#tiers) with a call limit (e.g. `ntfy tier create --call-limit=10 ...`), |
| 1779 |
and then assign it to a user. Users may then use the `X-Call` header to receive a phone call when publishing a message. |
| 1780 |
|
| 1781 |
To customize the message that is spoken out loud, set the `twilio-call-format` option with [TwiML](https://www.twilio.com/docs/voice/twiml). The format is |
| 1782 |
rendered as a [Go template](https://pkg.go.dev/text/template), so you can use the following fields from the message: |
| 1783 |
|
| 1784 |
* `{{.Topic}}` is the topic name |
| 1785 |
* `{{.Message}}` is the message body |
| 1786 |
* `{{.Title}}` is the message title |
| 1787 |
* `{{.Tags}}` is a list of tags |
| 1788 |
* `{{.Priority}}` is the message priority |
| 1789 |
* `{{.Sender}}` is the IP address or username of the sender |
| 1790 |
|
| 1791 |
Here's an example: |
| 1792 |
|
| 1793 |
=== "Custom TwiML (English)" |
| 1794 |
``` yaml |
| 1795 |
twilio-account: "AC12345beefbeef67890beefbeef122586" |
| 1796 |
twilio-auth-token: "affebeef258625862586258625862586" |
| 1797 |
twilio-phone-number: "+18775132586" |
| 1798 |
twilio-verify-service: "VA12345beefbeef67890beefbeef122586" |
| 1799 |
twilio-call-format: | |
| 1800 |
<Response> |
| 1801 |
<Pause length="1"/> |
| 1802 |
<Say loop="3"> |
| 1803 |
Yo yo yo, you should totally check out this message for {{.Topic}}. |
| 1804 |
{{ if eq .Priority 5 }} |
| 1805 |
It's really really important, dude. So listen up! |
| 1806 |
{{ end }} |
| 1807 |
<break time="1s"/> |
| 1808 |
{{ if neq .Title "" }} |
| 1809 |
Bro, it's titled: {{.Title}}. |
| 1810 |
{{ end }} |
| 1811 |
<break time="1s"/> |
| 1812 |
{{.Message}} |
| 1813 |
<break time="1s"/> |
| 1814 |
That is all. |
| 1815 |
<break time="1s"/> |
| 1816 |
You know who this message is from? It is from {{.Sender}}. |
| 1817 |
<break time="3s"/> |
| 1818 |
</Say> |
| 1819 |
<Say>See ya!</Say> |
| 1820 |
</Response> |
| 1821 |
``` |
| 1822 |
|
| 1823 |
=== "Custom TwiML (German)" |
| 1824 |
``` yaml |
| 1825 |
twilio-account: "AC12345beefbeef67890beefbeef122586" |
| 1826 |
twilio-auth-token: "affebeef258625862586258625862586" |
| 1827 |
twilio-phone-number: "+18775132586" |
| 1828 |
twilio-verify-service: "VA12345beefbeef67890beefbeef122586" |
| 1829 |
twilio-call-format: | |
| 1830 |
<Response> |
| 1831 |
<Pause length="1"/> |
| 1832 |
<Say loop="3" voice="alice" language="de-DE"> |
| 1833 |
Du hast eine Nachricht zum Thema {{.Topic}}. |
| 1834 |
{{ if eq .Priority 5 }} |
| 1835 |
Achtung. Die Nachricht ist sehr wichtig. |
| 1836 |
{{ end }} |
| 1837 |
<break time="1s"/> |
| 1838 |
{{ if neq .Title "" }} |
| 1839 |
Titel der Nachricht: {{.Title}}. |
| 1840 |
{{ end }} |
| 1841 |
<break time="1s"/> |
| 1842 |
Nachricht: |
| 1843 |
<break time="1s"/> |
| 1844 |
{{.Message}} |
| 1845 |
<break time="1s"/> |
| 1846 |
Ende der Nachricht. |
| 1847 |
<break time="1s"/> |
| 1848 |
Diese Nachricht wurde vom Benutzer {{.Sender}} gesendet. Sie wird drei Mal wiederholt. |
| 1849 |
<break time="3s"/> |
| 1850 |
</Say> |
| 1851 |
<Say voice="alice" language="de-DE">Alla mol!</Say> |
| 1852 |
</Response> |
| 1853 |
``` |
| 1854 |
|
| 1855 |
## Message limits |
| 1856 |
There are a few message limits that you can configure: |
| 1857 |
|
| 1858 |
* `message-size-limit` defines the max size of a message body. Please note message sizes >4K are **not recommended, |
| 1859 |
and largely untested**. The Android/iOS and other clients may not work, or work properly. If FCM and/or APNS is used, |
| 1860 |
the limit should stay 4K, because their limits are around that size. If you increase this size limit regardless, |
| 1861 |
FCM and APNS will NOT work for large messages. |
| 1862 |
* `message-delay-limit` defines the max delay of a message when using the "Delay" header and [scheduled delivery](publish.md#scheduled-delivery). |
| 1863 |
|
| 1864 |
## Rate limiting |
| 1865 |
!!! info |
| 1866 |
Be aware that if you are running ntfy behind a proxy, you must set the `behind-proxy` flag. |
| 1867 |
Otherwise, all visitors are rate limited as if they are one. |
| 1868 |
|
| 1869 |
By default, ntfy runs without authentication, so it is vitally important that we protect the server from abuse or overload. |
| 1870 |
There are various limits and rate limits in place that you can use to configure the server: |
| 1871 |
|
| 1872 |
* **Global limit**: A global limit applies across all visitors (IPs, clients, users) |
| 1873 |
* **Visitor limit**: A visitor limit only applies to a certain visitor. A **visitor** is identified by its IP address |
| 1874 |
(or the `X-Forwarded-For` header if `behind-proxy` is set). All config options that start with the word `visitor` apply |
| 1875 |
only on a per-visitor basis. |
| 1876 |
|
| 1877 |
During normal usage, you shouldn't encounter these limits at all, and even if you burst a few requests or emails |
| 1878 |
(e.g. when you reconnect after a connection drop), it shouldn't have any effect. |
| 1879 |
|
| 1880 |
### General limits |
| 1881 |
Let's do the easy limits first: |
| 1882 |
|
| 1883 |
* `global-topic-limit` defines the total number of topics before the server rejects new topics. It defaults to 15,000. |
| 1884 |
* `visitor-subscription-limit` is the number of subscriptions (open connections) per visitor. This value defaults to 30. |
| 1885 |
|
| 1886 |
### Request limits |
| 1887 |
In addition to the limits above, there is a requests/second limit per visitor for all sensitive GET/PUT/POST requests. |
| 1888 |
This limit uses a [token bucket](https://en.wikipedia.org/wiki/Token_bucket) (using Go's [rate package](https://pkg.go.dev/golang.org/x/time/rate)): |
| 1889 |
|
| 1890 |
Each visitor has a bucket of 60 requests they can fire against the server (defined by `visitor-request-limit-burst`). |
| 1891 |
After the 60, new requests will encounter a `429 Too Many Requests` response. The visitor request bucket is refilled at a rate of one |
| 1892 |
request every 5s (defined by `visitor-request-limit-replenish`) |
| 1893 |
|
| 1894 |
* `visitor-request-limit-burst` is the initial bucket of requests each visitor has. This defaults to 60. |
| 1895 |
* `visitor-request-limit-replenish` is the rate at which the bucket is refilled (one request per x). Defaults to 5s. |
| 1896 |
* `visitor-request-limit-exempt-hosts` is a comma-separated list of hostnames and IPs to be exempt from request rate |
| 1897 |
limiting; hostnames are resolved at the time the server is started. Defaults to an empty list. |
| 1898 |
|
| 1899 |
### Message limits |
| 1900 |
By default, the number of messages a visitor can send is governed entirely by the [request limit](#request-limits). |
| 1901 |
For instance, if the request limit allows for 15,000 requests per day, and all of those requests are POST/PUT requests |
| 1902 |
to publish messages, then that is the daily message limit. |
| 1903 |
|
| 1904 |
To limit the number of daily messages per visitor, you can set `visitor-message-daily-limit`. This defines the number |
| 1905 |
of messages a visitor can send in a day. This counter is reset every day at midnight (UTC). |
| 1906 |
|
| 1907 |
### Attachment limits |
| 1908 |
Aside from the global file size and total attachment cache limits (see [above](#attachments)), there are two relevant |
| 1909 |
per-visitor limits: |
| 1910 |
|
| 1911 |
* `visitor-attachment-total-size-limit` is the total storage limit used for attachments per visitor. It defaults to 100M. |
| 1912 |
The per-visitor storage is automatically decreased as attachments expire. External attachments (attached via `X-Attach`, |
| 1913 |
see [publishing docs](publish.md#attachments)) do not count here. |
| 1914 |
* `visitor-attachment-daily-bandwidth-limit` is the total daily attachment download/upload bandwidth limit per visitor, |
| 1915 |
including PUT and GET requests. This is to protect your precious bandwidth from abuse, since egress costs money in |
| 1916 |
most cloud providers. This defaults to 500M. |
| 1917 |
|
| 1918 |
### E-mail limits |
| 1919 |
Similarly to the request limit, there is also an e-mail limit (only relevant if [e-mail notifications](#e-mail-notifications) |
| 1920 |
are enabled): |
| 1921 |
|
| 1922 |
* `visitor-email-limit-burst` is the initial bucket of emails each visitor has. This defaults to 16. |
| 1923 |
* `visitor-email-limit-replenish` is the rate at which the bucket is refilled (one email per x). Defaults to 1h. |
| 1924 |
|
| 1925 |
### Topic creation limits |
| 1926 |
To mitigate topic-enumeration / squatting attacks (where a single source pokes thousands of guessable |
| 1927 |
topic names to inflate the server's in-memory topic map), there is a per-visitor limit on how many *new* |
| 1928 |
topics each visitor can cause to be created. Touching topics that already exist in memory does not consume |
| 1929 |
a token; only first-time insertions do. |
| 1930 |
|
| 1931 |
* `visitor-topic-creation-limit-burst` is the initial bucket of new-topic tokens. Set to 0 to disable |
| 1932 |
the limit entirely. Defaults to 100. |
| 1933 |
* `visitor-topic-creation-limit-replenish` is the rate at which the bucket is refilled (one new topic per x). |
| 1934 |
Defaults to 1m. |
| 1935 |
|
| 1936 |
### Firebase limits |
| 1937 |
If [Firebase is configured](#firebase-fcm), all messages are also published to a Firebase topic (unless `Firebase: no` |
| 1938 |
is set). Firebase enforces [its own limits](https://firebase.google.com/docs/cloud-messaging/concept-options#topics_throttling) |
| 1939 |
on how many messages can be published. Unfortunately these limits are a little vague and can change depending on the time |
| 1940 |
of day. In practice, I have only ever observed `429 Quota exceeded` responses from Firebase if **too many messages are published to |
| 1941 |
the same topic**. |
| 1942 |
|
| 1943 |
In ntfy, if Firebase responds with a 429 after publishing to a topic, the visitor (= IP address) who published the message |
| 1944 |
is **banned from publishing to Firebase for 10 minutes** (not configurable). Because publishing to Firebase happens asynchronously, |
| 1945 |
there is no indication of the user that this has happened. Non-Firebase subscribers (WebSocket or HTTP stream) are not affected. |
| 1946 |
After the 10 minutes are up, messages forwarding to Firebase is resumed for this visitor. |
| 1947 |
|
| 1948 |
If this ever happens, there will be a log message that looks something like this: |
| 1949 |
``` |
| 1950 |
WARN Firebase quota exceeded (likely for topic), temporarily denying Firebase access to visitor |
| 1951 |
``` |
| 1952 |
|
| 1953 |
### IPv6 considerations |
| 1954 |
By default, rate limiting for IPv6 is done using the `/64` subnet of the visitor's IPv6 address. This means that all visitors |
| 1955 |
in the same `/64` subnet are treated as one visitor. This is done to prevent abuse, as IPv6 subnet assignments are typically |
| 1956 |
much larger than IPv4 subnets (and much cheaper), and it is common for ISPs to assign large subnets to their customers. |
| 1957 |
|
| 1958 |
Other than that, rate limiting for IPv6 is done the same way as for IPv4, using the visitor's IP address or subnet to identify them. |
| 1959 |
|
| 1960 |
There are two options to configure the number of bits used for rate limiting (for IPv4 and IPv6): |
| 1961 |
|
| 1962 |
- `visitor-prefix-bits-ipv4` is number of bits of the IPv4 address to use for rate limiting (default: 32, full address) |
| 1963 |
- `visitor-prefix-bits-ipv6` is number of bits of the IPv6 address to use for rate limiting (default: 64, /64 subnet) |
| 1964 |
|
| 1965 |
### Subscriber-based rate limiting |
| 1966 |
By default, ntfy puts almost all rate limits on the message publisher, e.g. number of messages, requests, and attachment |
| 1967 |
size are all based on the visitor who publishes a message. **Subscriber-based rate limiting is a way to use the rate limits |
| 1968 |
of a topic's subscriber, instead of the limits of the publisher.** |
| 1969 |
|
| 1970 |
If subscriber-based rate limiting is enabled, **messages published on UnifiedPush topics** (topics starting with `up`, e.g. `up123456789012`) |
| 1971 |
will be counted towards the "rate visitor" of the topic. A "rate visitor" is the first subscriber to the topic. |
| 1972 |
|
| 1973 |
Once enabled, a client subscribing to UnifiedPush topics via HTTP stream, or websockets, will be automatically registered as |
| 1974 |
a "rate visitor", i.e. the visitor whose rate limits will be used when publishing on this topic. Note that setting the rate visitor |
| 1975 |
requires **read-write permission** on the topic. |
| 1976 |
|
| 1977 |
If this setting is enabled, publishing to UnifiedPush topics will lead to an `HTTP 507 Insufficient Storage` |
| 1978 |
response if no "rate visitor" has been previously registered. This is to avoid burning the publisher's |
| 1979 |
`visitor-message-daily-limit`. |
| 1980 |
|
| 1981 |
To enable subscriber-based rate limiting, set `visitor-subscriber-rate-limiting: true`. |
| 1982 |
|
| 1983 |
!!! info |
| 1984 |
Due to a [denial-of-service issue](https://github.com/binwiederhier/ntfy/issues/1048), support for the `Rate-Topics` |
| 1985 |
header was removed entirely. This is unfortunate, but subscriber-based rate limiting will still work for `up*` topics. |
| 1986 |
|
| 1987 |
## Tuning for scale |
| 1988 |
If you're running ntfy for your home server, you probably don't need to worry about scale at all. In its default config, |
| 1989 |
if it's not behind a proxy, the ntfy server can keep about **as many connections as the open file limit allows**. |
| 1990 |
This limit is typically called `nofile`. Other than that, RAM and CPU are obviously relevant. You may also want to check |
| 1991 |
out [this discussion on Reddit](https://www.reddit.com/r/golang/comments/r9u4ee/how_many_actively_connected_http_clients_can_a_go/). |
| 1992 |
|
| 1993 |
Depending on *how you run it*, here are a few limits that are relevant: |
| 1994 |
|
| 1995 |
### Message cache |
| 1996 |
By default, the [message cache](#message-cache) (defined by `cache-file`) uses the SQLite default settings, which means it |
| 1997 |
syncs to disk on every write. For personal servers, this is perfectly adequate. For larger installations, such as ntfy.sh, |
| 1998 |
the [write-ahead log (WAL)](https://sqlite.org/wal.html) should be enabled, and the sync mode should be adjusted. |
| 1999 |
See [this article](https://phiresky.github.io/blog/2020/sqlite-performance-tuning/) for details. |
| 2000 |
|
| 2001 |
In addition to that, for very high load servers (such as ntfy.sh), it may be beneficial to write messages to the cache |
| 2002 |
in batches, and asynchronously. This can be enabled with the `cache-batch-size` and `cache-batch-timeout`. If you start |
| 2003 |
seeing `database locked` messages in the logs, you should probably enable that. |
| 2004 |
|
| 2005 |
Here's how ntfy.sh has been tuned in the `server.yml` file: |
| 2006 |
|
| 2007 |
``` yaml |
| 2008 |
cache-batch-size: 25 |
| 2009 |
cache-batch-timeout: "1s" |
| 2010 |
cache-startup-queries: | |
| 2011 |
pragma journal_mode = WAL; |
| 2012 |
pragma synchronous = normal; |
| 2013 |
pragma temp_store = memory; |
| 2014 |
pragma busy_timeout = 15000; |
| 2015 |
vacuum; |
| 2016 |
``` |
| 2017 |
|
| 2018 |
### For systemd services |
| 2019 |
If you're running ntfy in a systemd service (e.g. for .deb/.rpm packages), the main limiting factor is the |
| 2020 |
`LimitNOFILE` setting in the systemd unit. The default open files limit for `ntfy.service` is 10,000. You can override it |
| 2021 |
by creating a `/etc/systemd/system/ntfy.service.d/override.conf` file. As far as I can tell, `/etc/security/limits.conf` |
| 2022 |
is not relevant. |
| 2023 |
|
| 2024 |
=== "/etc/systemd/system/ntfy.service.d/override.conf" |
| 2025 |
``` |
| 2026 |
# Allow 20,000 ntfy connections (and give room for other file handles) |
| 2027 |
[Service] |
| 2028 |
LimitNOFILE=20500 |
| 2029 |
``` |
| 2030 |
|
| 2031 |
### Outside of systemd |
| 2032 |
If you're running outside systemd, you may want to adjust your `/etc/security/limits.conf` file to |
| 2033 |
increase the `nofile` setting. Here's an example that increases the limit to 5,000. You can find out the current setting |
| 2034 |
by running `ulimit -n`, or manually override it temporarily by running `ulimit -n 50000`. |
| 2035 |
|
| 2036 |
=== "/etc/security/limits.conf" |
| 2037 |
``` |
| 2038 |
# Increase open files limit globally |
| 2039 |
* hard nofile 20500 |
| 2040 |
``` |
| 2041 |
|
| 2042 |
### Proxy limits (nginx, Apache2) |
| 2043 |
If you are running [behind a proxy](#behind-a-proxy-tls-etc) (e.g. nginx, Apache), the open files limit of the proxy is also |
| 2044 |
relevant. So if your proxy runs inside of systemd, increase the limits in systemd for the proxy. Typically, the proxy |
| 2045 |
open files limit has to be **double the number of how many connections you'd like to support**, because the proxy has |
| 2046 |
to maintain the client connection and the connection to ntfy. |
| 2047 |
|
| 2048 |
=== "/etc/nginx/nginx.conf" |
| 2049 |
``` |
| 2050 |
events { |
| 2051 |
# Allow 40,000 proxy connections (2x of the desired ntfy connection count; |
| 2052 |
# and give room for other file handles) |
| 2053 |
worker_connections 40500; |
| 2054 |
} |
| 2055 |
``` |
| 2056 |
|
| 2057 |
=== "/etc/systemd/system/nginx.service.d/override.conf" |
| 2058 |
``` |
| 2059 |
# Allow 40,000 proxy connections (2x of the desired ntfy connection count; |
| 2060 |
# and give room for other file handles) |
| 2061 |
[Service] |
| 2062 |
LimitNOFILE=40500 |
| 2063 |
``` |
| 2064 |
|
| 2065 |
### Banning bad actors (fail2ban) |
| 2066 |
If you put stuff on the Internet, bad actors will try to break them or break in. [fail2ban](https://www.fail2ban.org/) |
| 2067 |
and nginx's [ngx_http_limit_req_module module](http://nginx.org/en/docs/http/ngx_http_limit_req_module.html) can be used |
| 2068 |
to ban client IPs if they misbehave. This is on top of the [rate limiting](#rate-limiting) inside the ntfy server. |
| 2069 |
|
| 2070 |
Here's an example for how ntfy.sh is configured, following the instructions from two tutorials ([here](https://easyengine.io/tutorials/nginx/fail2ban/) |
| 2071 |
and [here](https://easyengine.io/tutorials/nginx/block-wp-login-php-bruteforce-attack/)): |
| 2072 |
|
| 2073 |
=== "/etc/nginx/nginx.conf" |
| 2074 |
``` |
| 2075 |
# Rate limit all IP addresses |
| 2076 |
http { |
| 2077 |
limit_req_zone $binary_remote_addr zone=one:10m rate=45r/m; |
| 2078 |
} |
| 2079 |
|
| 2080 |
# Alternatively, whitelist certain IP addresses |
| 2081 |
http { |
| 2082 |
geo $limited { |
| 2083 |
default 1; |
| 2084 |
116.203.112.46/32 0; |
| 2085 |
132.226.42.65/32 0; |
| 2086 |
... |
| 2087 |
} |
| 2088 |
map $limited $limitkey { |
| 2089 |
1 $binary_remote_addr; |
| 2090 |
0 ""; |
| 2091 |
} |
| 2092 |
limit_req_zone $limitkey zone=one:10m rate=45r/m; |
| 2093 |
} |
| 2094 |
``` |
| 2095 |
|
| 2096 |
=== "/etc/nginx/sites-enabled/ntfy.sh" |
| 2097 |
``` |
| 2098 |
# For each server/location block |
| 2099 |
server { |
| 2100 |
location / { |
| 2101 |
limit_req zone=one burst=1000 nodelay; |
| 2102 |
} |
| 2103 |
} |
| 2104 |
``` |
| 2105 |
|
| 2106 |
=== "/etc/fail2ban/filter.d/nginx-req-limit.conf" |
| 2107 |
``` |
| 2108 |
[Definition] |
| 2109 |
failregex = limiting requests, excess:.* by zone.*client: <HOST> |
| 2110 |
ignoreregex = |
| 2111 |
``` |
| 2112 |
|
| 2113 |
=== "/etc/fail2ban/jail.local" |
| 2114 |
``` |
| 2115 |
[nginx-req-limit] |
| 2116 |
enabled = true |
| 2117 |
filter = nginx-req-limit |
| 2118 |
action = iptables-multiport[name=ReqLimit, port="http,https", protocol=tcp] |
| 2119 |
logpath = /var/log/nginx/error.log |
| 2120 |
findtime = 600 |
| 2121 |
bantime = 14400 |
| 2122 |
maxretry = 10 |
| 2123 |
``` |
| 2124 |
|
| 2125 |
Note that if you run nginx in a container, append `, chain=DOCKER-USER` to the jail.local action. By default, the jail action chain |
| 2126 |
is `INPUT`, but `FORWARD` is used when using docker networks. `DOCKER-USER`, available when using docker, is part of the `FORWARD` |
| 2127 |
chain. |
| 2128 |
|
| 2129 |
The official ntfy.sh server uses fail2ban to ban IPs. Check out ntfy.sh's [Ansible fail2ban role](https://github.com/binwiederhier/ntfy-ansible/tree/main/roles/fail2ban) for details. Ban actors are banned for 1 hour initially, and up to |
| 2130 |
4 hours at a time for repeated offenses. IPv4 addresses are banned individually, while IPv6 addresses are banned by their `/56` prefix. |
| 2131 |
|
| 2132 |
### Ban-feed |
| 2133 |
In addition to the fail2ban setup above, ntfy can detect abusive visitors itself and write their IP |
| 2134 |
addresses to a file for fail2ban to ban from. ntfy keeps a per-prefix weighted "strike" budget, and |
| 2135 |
each rejected request costs strikes based on its response code -- the ntfy error code, or its HTTP |
| 2136 |
status (see `ban-weights`) -- so different kinds of rejection can be weighted differently or exempted |
| 2137 |
entirely. When a prefix exceeds the budget, ntfy appends the offending IP address to `ban-file`. Since |
| 2138 |
every line is already a confirmed offender, the fail2ban jail can ban on first sight (`maxretry = 1`). |
| 2139 |
|
| 2140 |
- `ban-file` is the file offenders are appended to. If it is not set, the ban-feed is disabled. Its |
| 2141 |
parent directory must exist and be writable by ntfy. Be sure to rotate it (e.g. with logrotate and |
| 2142 |
`copytruncate`) so it does not grow unbounded. |
| 2143 |
- `ban-window` is the rolling window over which weighted strikes are counted, per IP prefix. |
| 2144 |
- `ban-threshold` is the number of weighted strikes per `ban-window` before a prefix is written to |
| 2145 |
`ban-file`. Each prefix has one shared budget, so it cannot be gamed by mixing error codes. |
| 2146 |
- `ban-weights` assigns a strike weight per matcher key, formatted as `KEY:WEIGHT`. A key is an exact |
| 2147 |
ntfy error code (`42909`), a code family (`429*`, `403*`, `4*`), a bare HTTP status (`403`, short for |
| 2148 |
`403*`), or `*`. The longest matching key wins. A weight of `0` exempts a code entirely (it never |
| 2149 |
counts toward a ban), useful to spare a specific code from a `*` catch-all. Heavier weights ban faster. If you do not |
| 2150 |
include a `*` rule, any code that matches nothing defaults to weight `1` (i.e. it can be banned); |
| 2151 |
set `*:0` to exempt everything that is not explicitly weighted. |
| 2152 |
|
| 2153 |
Only rejections (4xx/5xx) count towards a ban; successful requests never do. Because the budget |
| 2154 |
refills over `ban-window`, the trigger is a sustained rate: a prefix is only written out once it |
| 2155 |
exceeds `ban-threshold / ban-window` rejections per second (with the defaults, `100 / 10m` = ~0.17/s). |
| 2156 |
|
| 2157 |
Each line in `ban-file` has the format `<RFC3339-timestamp> <ip> <prefix> <http-code> <ntfy-code>`, for example: |
| 2158 |
|
| 2159 |
``` |
| 2160 |
2026-01-15T20:56:32Z 1.2.3.4 1.2.3.4/32 429 42901 |
| 2161 |
2026-01-15T20:56:32Z 2001:db8::abcd 2001:db8::/64 429 42909 |
| 2162 |
``` |
| 2163 |
|
| 2164 |
`<prefix>` is `<ip>` masked to the rate-limiting prefix (`visitor-prefix-bits-ipv4`/`-ipv6`) -- the |
| 2165 |
same unit ntfy rate-limits by. Have the fail2ban filter capture the bare `<ip>` (the action then |
| 2166 |
applies the prefix): |
| 2167 |
|
| 2168 |
=== "server.yml" |
| 2169 |
```yaml |
| 2170 |
ban-file: "/var/log/ntfy/ban.log" |
| 2171 |
ban-window: "10m" |
| 2172 |
ban-threshold: 100 |
| 2173 |
ban-weights: |
| 2174 |
- "42909:10" # too many auth failures -> brute force, ban fast |
| 2175 |
# everything else 4xx/5xx defaults to weight 1 |
| 2176 |
``` |
| 2177 |
|
| 2178 |
=== "/etc/fail2ban/filter.d/ntfy-ban.conf" |
| 2179 |
``` |
| 2180 |
[Definition] |
| 2181 |
failregex = ^\S+ <HOST> \S+ \d+ \d+$ |
| 2182 |
datepattern = ^%%Y-%%m-%%dT%%H:%%M:%%S |
| 2183 |
ignoreregex = |
| 2184 |
``` |
| 2185 |
|
| 2186 |
=== "/etc/fail2ban/jail.d/ntfy-ban.local" |
| 2187 |
``` |
| 2188 |
[ntfy-ban] |
| 2189 |
enabled = true |
| 2190 |
filter = ntfy-ban |
| 2191 |
action = iptables-multiport[name=ntfy-ban, port="http,https", protocol=tcp] |
| 2192 |
logpath = /var/log/ntfy/ban.log |
| 2193 |
maxretry = 1 |
| 2194 |
findtime = 1m |
| 2195 |
bantime = 1h |
| 2196 |
``` |
| 2197 |
|
| 2198 |
## IPv6 support |
| 2199 |
ntfy fully supports IPv6, though there are a few things to keep in mind. |
| 2200 |
|
| 2201 |
- **Listening on an IPv6 address**: By default, ntfy listens on `:80` (IPv4-only). If you want to listen on an IPv6 address, you need to |
| 2202 |
explicitly set the `listen-http` and/or `listen-https` options in your `server.yml` file to an IPv6 address, e.g. `[::]:80`. To listen on |
| 2203 |
IPv4 and IPv6, you must run ntfy behind a reverse proxy, e.g. `listen :80; listen [::]:80;` in nginx. |
| 2204 |
- **Rate limiting:** By default, ntfy uses the `/64` subnet of the visitor's IPv6 address for rate limiting. This means that all visitors in the same `/64` |
| 2205 |
subnet are treated as one visitor. If you want to change this, you can set the `visitor-prefix-bits-ipv6` option in your `server.yml` file to a different |
| 2206 |
value (e.g. `48` for `/48` subnets). See [IPv6 considerations](#ipv6-considerations) and [IP-based rate limiting](#ip-based-rate-limiting) for more details. |
| 2207 |
- **Banning IPs with fail2ban:** By default, if you're using the `iptables-multiport` action, fail2ban bans individual IPv4 and IPv6 addresses via `iptables` and `ip6tables`. While this behavior is fine for IPv4, it is not for IPv6, because every host can technically have up to 2^64 addresses. Please ensure that your `actionban` and `actionunban` commands |
| 2208 |
support IPv6 and also ban the entire prefix (e.g. `/48`). See [Banning bad actors](#banning-bad-actors-fail2ban) for details. |
| 2209 |
|
| 2210 |
!!! info |
| 2211 |
The official ntfy.sh server supports IPv6. Check out ntfy.sh's [Ansible repository](https://github.com/binwiederhier/ntfy-ansible) for examples of how to |
| 2212 |
configure [ntfy](https://github.com/binwiederhier/ntfy-ansible/tree/main/roles/ntfy), [nginx](https://github.com/binwiederhier/ntfy-ansible/tree/main/roles/nginx) and [fail2ban](https://github.com/binwiederhier/ntfy-ansible/tree/main/roles/fail2ban). |
| 2213 |
|
| 2214 |
## Health checks |
| 2215 |
A preliminary health check API endpoint is exposed at `/v1/health`. The endpoint returns a `json` response in the format shown below. |
| 2216 |
If a non-200 HTTP status code is returned or if the returned `healthy` field is `false` the ntfy service should be considered as unhealthy. |
| 2217 |
|
| 2218 |
```json |
| 2219 |
{"healthy":true} |
| 2220 |
``` |
| 2221 |
|
| 2222 |
See [Installation for Docker](install.md#docker) for an example of how this could be used in a `docker-compose` environment. |
| 2223 |
|
| 2224 |
## Monitoring |
| 2225 |
If configured, ntfy can expose a `/metrics` endpoint for [Prometheus](https://prometheus.io/), which can then be used to |
| 2226 |
create dashboards and alerts (e.g. via [Grafana](https://grafana.com/)). |
| 2227 |
|
| 2228 |
To configure the metrics endpoint, either set `enable-metrics`, or set the `metrics-listen-http` option to a dedicated |
| 2229 |
listen address. Metrics may be considered sensitive information, so before you enable them, be sure you know what you are |
| 2230 |
doing, and/or secure access to the endpoint in your reverse proxy. |
| 2231 |
|
| 2232 |
- `enable-metrics` enables the /metrics endpoint for the default ntfy server (i.e. HTTP, HTTPS and/or Unix socket) |
| 2233 |
- `metrics-listen-http` moves the metrics endpoint to a dedicated `[IP]:port`, e.g. "10.0.1.1:9090" or ":9090". It |
| 2234 |
implicitly enables metrics. If set, the metrics are served only on that dedicated port, and the default ntfy server |
| 2235 |
does not serve /metrics, even if `enable-metrics` is also set. |
| 2236 |
|
| 2237 |
=== "server.yml (Using default port)" |
| 2238 |
```yaml |
| 2239 |
enable-metrics: true |
| 2240 |
``` |
| 2241 |
|
| 2242 |
=== "server.yml (Using dedicated IP/port)" |
| 2243 |
```yaml |
| 2244 |
metrics-listen-http: "10.0.1.1:9090" |
| 2245 |
``` |
| 2246 |
|
| 2247 |
In Prometheus, an example scrape config would look like this: |
| 2248 |
|
| 2249 |
=== "prometheus.yml" |
| 2250 |
```yaml |
| 2251 |
scrape_configs: |
| 2252 |
- job_name: "ntfy" |
| 2253 |
static_configs: |
| 2254 |
- targets: ["10.0.1.1:9090"] |
| 2255 |
``` |
| 2256 |
|
| 2257 |
Here's an example Grafana dashboard built from the metrics (see [Grafana JSON on GitHub](https://raw.githubusercontent.com/binwiederhier/ntfy/main/examples/grafana-dashboard/ntfy-grafana.json)): |
| 2258 |
|
| 2259 |
<figure markdown style="padding-left: 50px; padding-right: 50px"> |
| 2260 |
<a href="../../static/img/grafana-dashboard.png" target="_blank"><img src="../../static/img/grafana-dashboard.png"/></a> |
| 2261 |
<figcaption>ntfy Grafana dashboard</figcaption> |
| 2262 |
</figure> |
| 2263 |
|
| 2264 |
## Profiling |
| 2265 |
ntfy can expose Go's [net/http/pprof](https://pkg.go.dev/net/http/pprof) endpoints to support profiling of the ntfy server. |
| 2266 |
If enabled, ntfy will listen on a dedicated listen IP/port, which can be accessed via the web browser on `http://<ip>:<port>/debug/pprof/`. |
| 2267 |
This can be helpful to expose bottlenecks, and visualize call flows. To enable, simply set the `profile-listen-http` config option. |
| 2268 |
|
| 2269 |
## Logging & debugging |
| 2270 |
By default, ntfy logs to the console (stderr), with an `info` log level, and in a human-readable text format. |
| 2271 |
|
| 2272 |
ntfy supports five different log levels, can also write to a file, log as JSON, and even supports granular |
| 2273 |
log level overrides for easier debugging. Some options (`log-level` and `log-level-overrides`) can be hot reloaded |
| 2274 |
by calling `kill -HUP $pid` or `systemctl reload ntfy`. |
| 2275 |
|
| 2276 |
The following config options define the logging behavior: |
| 2277 |
|
| 2278 |
* `log-format` defines the output format, can be `text` (default) or `json` |
| 2279 |
* `log-file` is a filename to write logs to. If this is not set, ntfy logs to stderr. |
| 2280 |
* `log-level` defines the default log level, can be one of `trace`, `debug`, `info` (default), `warn` or `error`. |
| 2281 |
Be aware that `debug` (and particularly `trace`) can be **very verbose**. Only turn them on briefly for debugging purposes. |
| 2282 |
* `log-level-overrides` lets you override the log level if certain fields match. This is incredibly powerful |
| 2283 |
for debugging certain parts of the system (e.g. only the account management, or only a certain visitor). |
| 2284 |
This is an array of strings in the format: |
| 2285 |
- `field=value -> level` to match a value exactly, e.g. `tag=manager -> trace` |
| 2286 |
- `field -> level` to match any value, e.g. `time_taken_ms -> debug` |
| 2287 |
|
| 2288 |
**Logging config (good for production use):** |
| 2289 |
``` yaml |
| 2290 |
log-level: info |
| 2291 |
log-format: json |
| 2292 |
log-file: /var/log/ntfy.log |
| 2293 |
``` |
| 2294 |
|
| 2295 |
**Temporary debugging:** |
| 2296 |
If something's not working right, you can debug/trace through what the ntfy server is doing by setting the `log-level` |
| 2297 |
to `debug` or `trace`. The `debug` setting will output information about each published message, but not the message |
| 2298 |
contents. The `trace` setting will also print the message contents. |
| 2299 |
|
| 2300 |
Alternatively, you can set `log-level-overrides` for only certain fields, such as a visitor's IP address (`visitor_ip`), |
| 2301 |
a username (`user_name`), or a tag (`tag`). There are dozens of fields you can use to override log levels. To learn what |
| 2302 |
they are, either turn the log-level to `trace` and observe, or reference the [source code](https://github.com/binwiederhier/ntfy). |
| 2303 |
|
| 2304 |
Here's an example that will output only `info` log events, except when they match either of the defined overrides: |
| 2305 |
``` yaml |
| 2306 |
log-level: info |
| 2307 |
log-level-overrides: |
| 2308 |
- "tag=manager -> trace" |
| 2309 |
- "visitor_ip=1.2.3.4 -> debug" |
| 2310 |
- "time_taken_ms -> debug" |
| 2311 |
``` |
| 2312 |
|
| 2313 |
!!! warning |
| 2314 |
The `debug` and `trace` log levels are very verbose, and using `log-level-overrides` has a |
| 2315 |
performance penalty. Only use it for temporary debugging. |
| 2316 |
|
| 2317 |
You can also hot-reload the `log-level` and `log-level-overrides` by sending the `SIGHUP` signal to the process after |
| 2318 |
editing the `server.yml` file. You can do so by calling `systemctl reload ntfy` (if ntfy is running inside systemd), |
| 2319 |
or by calling `kill -HUP $(pidof ntfy)`. If successful, you'll see something like this: |
| 2320 |
|
| 2321 |
``` |
| 2322 |
$ ntfy serve |
| 2323 |
2022/06/02 10:29:28 INFO Listening on :2586[http] :1025[smtp], log level is INFO |
| 2324 |
2022/06/02 10:29:34 INFO Partially hot reloading configuration ... |
| 2325 |
2022/06/02 10:29:34 INFO Log level is TRACE |
| 2326 |
``` |
| 2327 |
|
| 2328 |
## Config options |
| 2329 |
Each config option can be set in the config file `/etc/ntfy/server.yml` (e.g. `listen-http: :80`) or as a |
| 2330 |
CLI option (e.g. `--listen-http :80`. Here's a list of all available options. Alternatively, you can set an environment |
| 2331 |
variable before running the `ntfy` command (e.g. `export NTFY_LISTEN_HTTP=:80`). |
| 2332 |
|
| 2333 |
!!! info |
| 2334 |
All config options can also be defined in the `server.yml` file using underscores instead of dashes, e.g. |
| 2335 |
`cache_duration` and `cache-duration` are both supported. This is to support stricter YAML parsers that do |
| 2336 |
not support dashes. |
| 2337 |
|
| 2338 |
| Config option | Env variable | Format | Default | Description | |
| 2339 |
|--------------------------------------------|-------------------------------------------------|-----------------------------------------------------|-------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |
| 2340 |
| `base-url` | `NTFY_BASE_URL` | *URL* | - | Public facing base URL of the service (e.g. `https://ntfy.sh`) | |
| 2341 |
| `listen-http` | `NTFY_LISTEN_HTTP` | `[host]:port` | `:80` | Listen address for the HTTP web server | |
| 2342 |
| `listen-https` | `NTFY_LISTEN_HTTPS` | `[host]:port` | - | Listen address for the HTTPS web server. If set, you also need to set `key-file` and `cert-file`. | |
| 2343 |
| `listen-unix` | `NTFY_LISTEN_UNIX` | *filename* | - | Path to a Unix socket to listen on | |
| 2344 |
| `listen-unix-mode` | `NTFY_LISTEN_UNIX_MODE` | *file mode* | *system default* | File mode of the Unix socket, e.g. 0700 or 0777 | |
| 2345 |
| `key-file` | `NTFY_KEY_FILE` | *filename* | - | HTTPS/TLS private key file, only used if `listen-https` is set. | |
| 2346 |
| `cert-file` | `NTFY_CERT_FILE` | *filename* | - | HTTPS/TLS certificate file, only used if `listen-https` is set. | |
| 2347 |
| `firebase-key-file` | `NTFY_FIREBASE_KEY_FILE` | *filename* | - | If set, also publish messages to a Firebase Cloud Messaging (FCM) topic for your app. This is optional and only required to save battery when using the Android app. See [Firebase (FCM)](#firebase-fcm). | |
| 2348 |
| `database-url` | `NTFY_DATABASE_URL` | *string (connection URL)* | - | PostgreSQL connection string (e.g. `postgres://user:pass@host:5432/ntfy`). If set, uses PostgreSQL for all database-backed stores (message cache, user manager, web push) instead of SQLite. See [database options](#database-options). | |
| 2349 |
| `database-replica-urls` | `NTFY_DATABASE_REPLICA_URLS` | *list of strings (connection URLs)* | - | PostgreSQL read replica connection strings. Non-critical read-only queries are distributed across replicas (round-robin) with automatic fallback to primary. Requires `database-url`. | |
| 2350 |
| `cache-file` | `NTFY_CACHE_FILE` | *filename* | - | If set, messages are cached in a local SQLite database instead of only in-memory. This allows for service restarts without losing messages in support of the since= parameter. See [message cache](#message-cache). | |
| 2351 |
| `cache-duration` | `NTFY_CACHE_DURATION` | *duration* | 12h | Duration for which messages will be buffered before they are deleted. This is required to support the `since=...` and `poll=1` parameter. Set this to `0` to disable the cache entirely. | |
| 2352 |
| `cache-startup-queries` | `NTFY_CACHE_STARTUP_QUERIES` | *string (SQL queries)* | - | SQL queries to run during database startup; this is useful for tuning and [enabling WAL mode](#message-cache) | |
| 2353 |
| `cache-batch-size` | `NTFY_CACHE_BATCH_SIZE` | *int* | 0 | Max size of messages to batch together when writing to message cache (if zero, writes are synchronous) | |
| 2354 |
| `cache-batch-timeout` | `NTFY_CACHE_BATCH_TIMEOUT` | *duration* | 0s | Timeout for batched async writes to the message cache (if zero, writes are synchronous) | |
| 2355 |
| `auth-file` | `NTFY_AUTH_FILE` | *filename* | - | Auth database file used for access control (SQLite). If set, enables authentication and access control. Not required if `database-url` is set. See [access control](#access-control). | |
| 2356 |
| `auth-default-access` | `NTFY_AUTH_DEFAULT_ACCESS` | `read-write`, `read-only`, `write-only`, `deny-all` | `read-write` | Default permissions if no matching entries in the auth database are found. Default is `read-write`. | |
| 2357 |
| `auth-access-cache` | `NTFY_AUTH_ACCESS_CACHE` | *bool* | false | Enables an in-memory ACL cache so authorization checks no longer hit the database. Only worth enabling on high-volume servers. | |
| 2358 |
| `behind-proxy` | `NTFY_BEHIND_PROXY` | *bool* | false | If set, use forwarded header (e.g. X-Forwarded-For, X-Client-IP) to determine visitor IP address (for rate limiting) | |
| 2359 |
| `proxy-forwarded-header` | `NTFY_PROXY_FORWARDED_HEADER` | *string* | `X-Forwarded-For` | Use specified header to determine visitor IP address (for rate limiting) | |
| 2360 |
| `proxy-trusted-hosts` | `NTFY_PROXY_TRUSTED_HOSTS` | *comma-separated host/IP/CIDR list* | - | Comma-separated list of trusted IP addresses, hosts, or CIDRs to remove from forwarded header | |
| 2361 |
| `attachment-cache-dir` | `NTFY_ATTACHMENT_CACHE_DIR` | *directory or S3 URL* | - | Cache directory for attached files, or S3 URL for object storage (format: `s3://KEY:SECRET@BUCKET[/PREFIX]?region=REGION[&endpoint=ENDPOINT][&disable_http2=true]`). | |
| 2362 |
| `attachment-total-size-limit` | `NTFY_ATTACHMENT_TOTAL_SIZE_LIMIT` | *size* | 5G | Limit of the on-disk attachment cache directory. If the limits is exceeded, new attachments will be rejected. | |
| 2363 |
| `attachment-file-size-limit` | `NTFY_ATTACHMENT_FILE_SIZE_LIMIT` | *size* | 15M | Per-file attachment size limit (e.g. 300k, 2M, 100M). Larger attachment will be rejected. | |
| 2364 |
| `attachment-expiry-duration` | `NTFY_ATTACHMENT_EXPIRY_DURATION` | *duration* | 3h | Duration after which uploaded attachments will be deleted (e.g. 3h, 20h). Strongly affects `visitor-attachment-total-size-limit`. | |
| 2365 |
| `smtp-sender-addr` | `NTFY_SMTP_SENDER_ADDR` | `host:port` | - | SMTP server address to allow email sending | |
| 2366 |
| `smtp-sender-user` | `NTFY_SMTP_SENDER_USER` | *string* | - | SMTP user; only used if e-mail sending is enabled | |
| 2367 |
| `smtp-sender-pass` | `NTFY_SMTP_SENDER_PASS` | *string* | - | SMTP password; only used if e-mail sending is enabled | |
| 2368 |
| `smtp-sender-from` | `NTFY_SMTP_SENDER_FROM` | *e-mail address* | - | SMTP sender e-mail address; only used if e-mail sending is enabled | |
| 2369 |
| `smtp-sender-verify` | `NTFY_SMTP_SENDER_VERIFY` | *bool* | `false` | If true, require verified email addresses for email notifications; anonymous email sending is disabled | |
| 2370 |
| `smtp-server-listen` | `NTFY_SMTP_SERVER_LISTEN` | `[ip]:port` | - | Defines the IP address and port the SMTP server will listen on, e.g. `:25` or `1.2.3.4:25` | |
| 2371 |
| `smtp-server-domain` | `NTFY_SMTP_SERVER_DOMAIN` | *domain name* | - | SMTP server e-mail domain, e.g. `ntfy.sh` | |
| 2372 |
| `smtp-server-addr-prefix` | `NTFY_SMTP_SERVER_ADDR_PREFIX` | *string* | - | Optional prefix for the e-mail addresses to prevent spam, e.g. `ntfy-` | |
| 2373 |
| `twilio-account` | `NTFY_TWILIO_ACCOUNT` | *string* | - | Twilio account SID, e.g. AC12345beefbeef67890beefbeef122586 | |
| 2374 |
| `twilio-auth-token` | `NTFY_TWILIO_AUTH_TOKEN` | *string* | - | Twilio auth token, e.g. affebeef258625862586258625862586 | |
| 2375 |
| `twilio-phone-number` | `NTFY_TWILIO_PHONE_NUMBER` | *string* | - | Twilio outgoing phone number, e.g. +18775132586 | |
| 2376 |
| `twilio-verify-service` | `NTFY_TWILIO_VERIFY_SERVICE` | *string* | - | Twilio Verify service SID, e.g. VA12345beefbeef67890beefbeef122586 | |
| 2377 |
| `keepalive-interval` | `NTFY_KEEPALIVE_INTERVAL` | *duration* | 45s | Interval in which keepalive messages are sent to the client. This is to prevent intermediaries closing the connection for inactivity. Note that the Android app has a hardcoded timeout at 77s, so it should be less than that. | |
| 2378 |
| `manager-interval` | `NTFY_MANAGER_INTERVAL` | *duration* | 1m | Interval in which the manager prunes old messages, deletes topics and prints the stats. | |
| 2379 |
| `message-size-limit` | `NTFY_MESSAGE_SIZE_LIMIT` | *size* | 4K | The size limit for the message body. Please note that this is largely untested, and that FCM/APNS have limits around 4KB. If you increase this size limit, FCM and APNS will NOT work for large messages. | |
| 2380 |
| `message-delay-limit` | `NTFY_MESSAGE_DELAY_LIMIT` | *duration* | 3d | Amount of time a message can be [scheduled](publish.md#scheduled-delivery) into the future when using the `Delay` header | |
| 2381 |
| `global-topic-limit` | `NTFY_GLOBAL_TOPIC_LIMIT` | *number* | 15,000 | Rate limiting: Total number of topics before the server rejects new topics. | |
| 2382 |
| `upstream-base-url` | `NTFY_UPSTREAM_BASE_URL` | *URL* | `https://ntfy.sh` | Forward poll request to an upstream server, this is needed for iOS push notifications for self-hosted servers | |
| 2383 |
| `upstream-access-token` | `NTFY_UPSTREAM_ACCESS_TOKEN` | *string* | `tk_zyYLYj...` | Access token to use for the upstream server; needed only if upstream rate limits are exceeded or upstream server requires auth | |
| 2384 |
| `visitor-attachment-total-size-limit` | `NTFY_VISITOR_ATTACHMENT_TOTAL_SIZE_LIMIT` | *size* | 100M | Rate limiting: Total storage limit used for attachments per visitor, for all attachments combined. Storage is freed after attachments expire. See `attachment-expiry-duration`. | |
| 2385 |
| `visitor-attachment-daily-bandwidth-limit` | `NTFY_VISITOR_ATTACHMENT_DAILY_BANDWIDTH_LIMIT` | *size* | 500M | Rate limiting: Total daily attachment download/upload traffic limit per visitor. This is to protect your bandwidth costs from exploding. | |
| 2386 |
| `visitor-email-limit-burst` | `NTFY_VISITOR_EMAIL_LIMIT_BURST` | *number* | 16 | Rate limiting:Initial limit of e-mails per visitor | |
| 2387 |
| `visitor-email-limit-replenish` | `NTFY_VISITOR_EMAIL_LIMIT_REPLENISH` | *duration* | 1h | Rate limiting: Strongly related to `visitor-email-limit-burst`: The rate at which the bucket is refilled | |
| 2388 |
| `visitor-message-daily-limit` | `NTFY_VISITOR_MESSAGE_DAILY_LIMIT` | *number* | - | Rate limiting: Allowed number of messages per day per visitor, reset every day at midnight (UTC). By default, this value is unset. | |
| 2389 |
| `visitor-request-limit-burst` | `NTFY_VISITOR_REQUEST_LIMIT_BURST` | *number* | 60 | Rate limiting: Allowed GET/PUT/POST requests per second, per visitor. This setting is the initial bucket of requests each visitor has | |
| 2390 |
| `visitor-request-limit-replenish` | `NTFY_VISITOR_REQUEST_LIMIT_REPLENISH` | *duration* | 5s | Rate limiting: Strongly related to `visitor-request-limit-burst`: The rate at which the bucket is refilled | |
| 2391 |
| `visitor-request-limit-exempt-hosts` | `NTFY_VISITOR_REQUEST_LIMIT_EXEMPT_HOSTS` | *comma-separated host/IP/CIDR list* | - | Rate limiting: List of hostnames and IPs to be exempt from request rate limiting | |
| 2392 |
| `visitor-subscription-limit` | `NTFY_VISITOR_SUBSCRIPTION_LIMIT` | *number* | 30 | Rate limiting: Number of subscriptions per visitor (IP address) | |
| 2393 |
| `visitor-subscriber-rate-limiting` | `NTFY_VISITOR_SUBSCRIBER_RATE_LIMITING` | *bool* | `false` | Rate limiting: Enables subscriber-based rate limiting | |
| 2394 |
| `visitor-topic-creation-limit-burst` | `NTFY_VISITOR_TOPIC_CREATION_LIMIT_BURST` | *number* | 100 | Rate limiting: Initial bucket of new topic creations per visitor. 0 disables the limit. | |
| 2395 |
| `visitor-topic-creation-limit-replenish` | `NTFY_VISITOR_TOPIC_CREATION_LIMIT_REPLENISH` | *duration* | 1m | Rate limiting: Rate at which the per-visitor topic-creation bucket is refilled (one new topic per x). | |
| 2396 |
| `visitor-prefix-bits-ipv4` | `NTFY_VISITOR_PREFIX_BITS_IPV4` | *number* | 32 | Rate limiting: Number of bits to use for IPv4 visitor prefix, e.g. 24 for /24 | |
| 2397 |
| `visitor-prefix-bits-ipv6` | `NTFY_VISITOR_PREFIX_BITS_IPV6` | *number* | 64 | Rate limiting: Number of bits to use for IPv6 visitor prefix, e.g. 48 for /48 | |
| 2398 |
| `ban-file` | `NTFY_BAN_FILE` | *filename* | - | Abuse ban-feed: file confirmed abusive visitor IPs are appended to, for fail2ban to tail. Empty disables the feature. See [Banning bad actors](#banning-bad-actors-fail2ban) | |
| 2399 |
| `ban-window` | `NTFY_BAN_WINDOW` | *duration* | 10m | Abuse ban-feed: rolling window over which weighted strikes are counted, per IP prefix | |
| 2400 |
| `ban-threshold` | `NTFY_BAN_THRESHOLD` | *number* | 100 | Abuse ban-feed: weighted strikes per `ban-window` before a prefix is written to `ban-file` | |
| 2401 |
| `ban-weights` | `NTFY_BAN_WEIGHTS` | *list of KEY:WEIGHT* | `42909:10`| Abuse ban-feed: per-code strike weights (exact code, family `429*`, or `*`; longest match wins; `0` exempts). See [Banning bad actors](#banning-bad-actors-fail2ban) | |
| 2402 |
| `web-root` | `NTFY_WEB_ROOT` | *path*, e.g. `/` or `/app`, or `disable` | `/` | Sets root of the web app (e.g. /, or /app), or disables it entirely (disable) | |
| 2403 |
| `enable-signup` | `NTFY_ENABLE_SIGNUP` | *boolean* (`true` or `false`) | `false` | Allows users to sign up via the web app, or API | |
| 2404 |
| `enable-login` | `NTFY_ENABLE_LOGIN` | *boolean* (`true` or `false`) | `false` | Allows users to log in via the web app, or API | |
| 2405 |
| `enable-reservations` | `NTFY_ENABLE_RESERVATIONS` | *boolean* (`true` or `false`) | `false` | Allows users to reserve topics (if their tier allows it) | |
| 2406 |
| `require-login` | `NTFY_REQUIRE_LOGIN` | *boolean* (`true` or `false`) | `false` | All actions via the web app require a login | |
| 2407 |
| `stripe-secret-key` | `NTFY_STRIPE_SECRET_KEY` | *string* | - | Payments: Key used for the Stripe API communication, this enables payments | |
| 2408 |
| `stripe-webhook-key` | `NTFY_STRIPE_WEBHOOK_KEY` | *string* | - | Payments: Key required to validate the authenticity of incoming webhooks from Stripe | |
| 2409 |
| `billing-contact` | `NTFY_BILLING_CONTACT` | *email address* or *website* | - | Payments: Email or website displayed in Upgrade dialog as a billing contact | |
| 2410 |
| `web-push-public-key` | `NTFY_WEB_PUSH_PUBLIC_KEY` | *string* | - | Web Push: Public Key. Run `ntfy webpush keys` to generate | |
| 2411 |
| `web-push-private-key` | `NTFY_WEB_PUSH_PRIVATE_KEY` | *string* | - | Web Push: Private Key. Run `ntfy webpush keys` to generate | |
| 2412 |
| `web-push-file` | `NTFY_WEB_PUSH_FILE` | *string* | - | Web Push: Database file that stores subscriptions | |
| 2413 |
| `web-push-email-address` | `NTFY_WEB_PUSH_EMAIL_ADDRESS` | *string* | - | Web Push: Sender email address | |
| 2414 |
| `web-push-startup-queries` | `NTFY_WEB_PUSH_STARTUP_QUERIES` | *string* | - | Web Push: SQL queries to run against subscription database at startup | |
| 2415 |
| `web-push-expiry-duration` | `NTFY_WEB_PUSH_EXPIRY_DURATION` | *duration* | 60d | Web Push: Duration after which a subscription is considered stale and will be deleted. This is to prevent stale subscriptions. | |
| 2416 |
| `web-push-expiry-warning-duration` | `NTFY_WEB_PUSH_EXPIRY_WARNING_DURATION` | *duration* | 55d | Web Push: Duration after which a warning is sent to subscribers that their subscription will expire soon. This is to prevent stale subscriptions. | |
| 2417 |
| `log-format` | `NTFY_LOG_FORMAT` | *string* | `text` | Defines the output format, can be text or json | |
| 2418 |
| `log-file` | `NTFY_LOG_FILE` | *string* | - | Defines the filename to write logs to. If this is not set, ntfy logs to stderr | |
| 2419 |
| `log-level` | `NTFY_LOG_LEVEL` | *string* | `info` | Defines the default log level, can be one of trace, debug, info, warn or error | |
| 2420 |
|
| 2421 |
The format for a *duration* is: `<number>(smhd)`, e.g. 30s, 20m, 1h or 3d. |
| 2422 |
The format for a *size* is: `<number>(GMK)`, e.g. 1G, 200M or 4000k. |
| 2423 |
|
| 2424 |
## Command line options |
| 2425 |
``` |
| 2426 |
NAME: |
| 2427 |
ntfy serve - Run the ntfy server |
| 2428 |
|
| 2429 |
USAGE: |
| 2430 |
ntfy serve [OPTIONS..] |
| 2431 |
|
| 2432 |
CATEGORY: |
| 2433 |
Server commands |
| 2434 |
|
| 2435 |
DESCRIPTION: |
| 2436 |
Run the ntfy server and listen for incoming requests |
| 2437 |
|
| 2438 |
The command will load the configuration from /etc/ntfy/server.yml. Config options can |
| 2439 |
be overridden using the command line options. |
| 2440 |
|
| 2441 |
Examples: |
| 2442 |
ntfy serve # Starts server in the foreground (on port 80) |
| 2443 |
ntfy serve --listen-http :8080 # Starts server with alternate port |
| 2444 |
|
| 2445 |
OPTIONS: |
| 2446 |
--debug, -d enable debug logging (default: false) [$NTFY_DEBUG] |
| 2447 |
--trace enable tracing (very verbose, be careful) (default: false) [$NTFY_TRACE] |
| 2448 |
--no-log-dates, --no_log_dates disable the date/time prefix (default: false) [$NTFY_NO_LOG_DATES] |
| 2449 |
--log-level value, --log_level value set log level (default: "INFO") [$NTFY_LOG_LEVEL] |
| 2450 |
--log-level-overrides value, --log_level_overrides value [ --log-level-overrides value, --log_level_overrides value ] set log level overrides [$NTFY_LOG_LEVEL_OVERRIDES] |
| 2451 |
--log-format value, --log_format value set log format (default: "text") [$NTFY_LOG_FORMAT] |
| 2452 |
--log-file value, --log_file value set log file, default is STDOUT [$NTFY_LOG_FILE] |
| 2453 |
--config value, -c value config file (default: "/etc/ntfy/server.yml") [$NTFY_CONFIG_FILE] |
| 2454 |
--base-url value, --base_url value, -B value externally visible base URL for this host (e.g. https://ntfy.sh) [$NTFY_BASE_URL] |
| 2455 |
--listen-http value, --listen_http value, -l value ip:port used as HTTP listen address (default: ":80") [$NTFY_LISTEN_HTTP] |
| 2456 |
--listen-https value, --listen_https value, -L value ip:port used as HTTPS listen address [$NTFY_LISTEN_HTTPS] |
| 2457 |
--listen-unix value, --listen_unix value, -U value listen on unix socket path [$NTFY_LISTEN_UNIX] |
| 2458 |
--listen-unix-mode value, --listen_unix_mode value file permissions of unix socket, e.g. 0700 (default: system default) [$NTFY_LISTEN_UNIX_MODE] |
| 2459 |
--key-file value, --key_file value, -K value private key file, if listen-https is set [$NTFY_KEY_FILE] |
| 2460 |
--cert-file value, --cert_file value, -E value certificate file, if listen-https is set [$NTFY_CERT_FILE] |
| 2461 |
--firebase-key-file value, --firebase_key_file value, -F value Firebase credentials file; if set additionally publish to FCM topic [$NTFY_FIREBASE_KEY_FILE] |
| 2462 |
--cache-file value, --cache_file value, -C value cache file used for message caching [$NTFY_CACHE_FILE] |
| 2463 |
--cache-duration since, --cache_duration since, -b since buffer messages for this time to allow since requests (default: "12h") [$NTFY_CACHE_DURATION] |
| 2464 |
--cache-batch-size value, --cache_batch_size value max size of messages to batch together when writing to message cache (if zero, writes are synchronous) (default: 0) [$NTFY_BATCH_SIZE] |
| 2465 |
--cache-batch-timeout value, --cache_batch_timeout value timeout for batched async writes to the message cache (if zero, writes are synchronous) (default: "0s") [$NTFY_CACHE_BATCH_TIMEOUT] |
| 2466 |
--cache-startup-queries value, --cache_startup_queries value queries run when the cache database is initialized [$NTFY_CACHE_STARTUP_QUERIES] |
| 2467 |
--auth-file value, --auth_file value, -H value auth database file used for access control [$NTFY_AUTH_FILE] |
| 2468 |
--auth-startup-queries value, --auth_startup_queries value queries run when the auth database is initialized [$NTFY_AUTH_STARTUP_QUERIES] |
| 2469 |
--auth-default-access value, --auth_default_access value, -p value default permissions if no matching entries in the auth database are found (default: "read-write") [$NTFY_AUTH_DEFAULT_ACCESS] |
| 2470 |
--auth-access-cache, --auth_access_cache enables the in-memory ACL cache (high-volume servers only) (default: false) [$NTFY_AUTH_ACCESS_CACHE] |
| 2471 |
--attachment-cache-dir value, --attachment_cache_dir value cache directory for attached files, or S3 URL (s3://ACCESS_KEY:SECRET_KEY@BUCKET[/PREFIX]?region=REGION[&endpoint=ENDPOINT][&disable_http2=true]) [$NTFY_ATTACHMENT_CACHE_DIR] |
| 2472 |
--attachment-total-size-limit value, --attachment_total_size_limit value, -A value limit of the on-disk attachment cache (default: "5G") [$NTFY_ATTACHMENT_TOTAL_SIZE_LIMIT] |
| 2473 |
--attachment-file-size-limit value, --attachment_file_size_limit value, -Y value per-file attachment size limit (e.g. 300k, 2M, 100M) (default: "15M") [$NTFY_ATTACHMENT_FILE_SIZE_LIMIT] |
| 2474 |
--attachment-expiry-duration value, --attachment_expiry_duration value, -X value duration after which uploaded attachments will be deleted (e.g. 3h, 20h) (default: "3h") [$NTFY_ATTACHMENT_EXPIRY_DURATION] |
| 2475 |
--keepalive-interval value, --keepalive_interval value, -k value interval of keepalive messages (default: "45s") [$NTFY_KEEPALIVE_INTERVAL] |
| 2476 |
--manager-interval value, --manager_interval value, -m value interval of for message pruning and stats printing (default: "1m") [$NTFY_MANAGER_INTERVAL] |
| 2477 |
--disallowed-topics value, --disallowed_topics value [ --disallowed-topics value, --disallowed_topics value ] topics that are not allowed to be used [$NTFY_DISALLOWED_TOPICS] |
| 2478 |
--web-root value, --web_root value sets root of the web app (e.g. /, or /app), or disables it (disable) (default: "/") [$NTFY_WEB_ROOT] |
| 2479 |
--enable-signup, --enable_signup allows users to sign up via the web app, or API (default: false) [$NTFY_ENABLE_SIGNUP] |
| 2480 |
--enable-login, --enable_login allows users to log in via the web app, or API (default: false) [$NTFY_ENABLE_LOGIN] |
| 2481 |
--enable-reservations, --enable_reservations allows users to reserve topics (if their tier allows it) (default: false) [$NTFY_ENABLE_RESERVATIONS] |
| 2482 |
--upstream-base-url value, --upstream_base_url value forward poll request to an upstream server, this is needed for iOS push notifications for self-hosted servers [$NTFY_UPSTREAM_BASE_URL] |
| 2483 |
--upstream-access-token value, --upstream_access_token value access token to use for the upstream server; needed only if upstream rate limits are exceeded or upstream server requires auth [$NTFY_UPSTREAM_ACCESS_TOKEN] |
| 2484 |
--smtp-sender-addr value, --smtp_sender_addr value SMTP server address (host:port) for outgoing emails [$NTFY_SMTP_SENDER_ADDR] |
| 2485 |
--smtp-sender-user value, --smtp_sender_user value SMTP user (if e-mail sending is enabled) [$NTFY_SMTP_SENDER_USER] |
| 2486 |
--smtp-sender-pass value, --smtp_sender_pass value SMTP password (if e-mail sending is enabled) [$NTFY_SMTP_SENDER_PASS] |
| 2487 |
--smtp-sender-from value, --smtp_sender_from value SMTP sender address (if e-mail sending is enabled) [$NTFY_SMTP_SENDER_FROM] |
| 2488 |
--smtp-server-listen value, --smtp_server_listen value SMTP server address (ip:port) for incoming emails, e.g. :25 [$NTFY_SMTP_SERVER_LISTEN] |
| 2489 |
--smtp-server-domain value, --smtp_server_domain value SMTP domain for incoming e-mail, e.g. ntfy.sh [$NTFY_SMTP_SERVER_DOMAIN] |
| 2490 |
--smtp-server-addr-prefix value, --smtp_server_addr_prefix value SMTP email address prefix for topics to prevent spam (e.g. 'ntfy-') [$NTFY_SMTP_SERVER_ADDR_PREFIX] |
| 2491 |
--twilio-account value, --twilio_account value Twilio account SID, used for phone calls, e.g. AC123... [$NTFY_TWILIO_ACCOUNT] |
| 2492 |
--twilio-auth-token value, --twilio_auth_token value Twilio auth token [$NTFY_TWILIO_AUTH_TOKEN] |
| 2493 |
--twilio-phone-number value, --twilio_phone_number value Twilio number to use for outgoing calls [$NTFY_TWILIO_PHONE_NUMBER] |
| 2494 |
--twilio-verify-service value, --twilio_verify_service value Twilio Verify service ID, used for phone number verification [$NTFY_TWILIO_VERIFY_SERVICE] |
| 2495 |
--message-size-limit value, --message_size_limit value size limit for the message (see docs for limitations) (default: "4K") [$NTFY_MESSAGE_SIZE_LIMIT] |
| 2496 |
--message-delay-limit value, --message_delay_limit value max duration a message can be scheduled into the future (default: "3d") [$NTFY_MESSAGE_DELAY_LIMIT] |
| 2497 |
--global-topic-limit value, --global_topic_limit value, -T value total number of topics allowed (default: 15000) [$NTFY_GLOBAL_TOPIC_LIMIT] |
| 2498 |
--visitor-subscription-limit value, --visitor_subscription_limit value number of subscriptions per visitor (default: 30) [$NTFY_VISITOR_SUBSCRIPTION_LIMIT] |
| 2499 |
--visitor-subscriber-rate-limiting, --visitor_subscriber_rate_limiting enables subscriber-based rate limiting (default: false) [$NTFY_VISITOR_SUBSCRIBER_RATE_LIMITING] |
| 2500 |
--visitor-attachment-total-size-limit value, --visitor_attachment_total_size_limit value total storage limit used for attachments per visitor (default: "100M") [$NTFY_VISITOR_ATTACHMENT_TOTAL_SIZE_LIMIT] |
| 2501 |
--visitor-attachment-daily-bandwidth-limit value, --visitor_attachment_daily_bandwidth_limit value total daily attachment download/upload bandwidth limit per visitor (default: "500M") [$NTFY_VISITOR_ATTACHMENT_DAILY_BANDWIDTH_LIMIT] |
| 2502 |
--visitor-request-limit-burst value, --visitor_request_limit_burst value initial limit of requests per visitor (default: 60) [$NTFY_VISITOR_REQUEST_LIMIT_BURST] |
| 2503 |
--visitor-request-limit-replenish value, --visitor_request_limit_replenish value interval at which burst limit is replenished (one per x) (default: "5s") [$NTFY_VISITOR_REQUEST_LIMIT_REPLENISH] |
| 2504 |
--visitor-request-limit-exempt-hosts value, --visitor_request_limit_exempt_hosts value hostnames and/or IP addresses of hosts that will be exempt from the visitor request limit [$NTFY_VISITOR_REQUEST_LIMIT_EXEMPT_HOSTS] |
| 2505 |
--visitor-message-daily-limit value, --visitor_message_daily_limit value max messages per visitor per day, derived from request limit if unset (default: 0) [$NTFY_VISITOR_MESSAGE_DAILY_LIMIT] |
| 2506 |
--visitor-email-limit-burst value, --visitor_email_limit_burst value initial limit of e-mails per visitor (default: 16) [$NTFY_VISITOR_EMAIL_LIMIT_BURST] |
| 2507 |
--visitor-email-limit-replenish value, --visitor_email_limit_replenish value interval at which burst limit is replenished (one per x) (default: "1h") [$NTFY_VISITOR_EMAIL_LIMIT_REPLENISH] |
| 2508 |
--visitor-topic-creation-limit-burst value, --visitor_topic_creation_limit_burst value burst of new topic creations per visitor (0 = disabled) (default: 100) [$NTFY_VISITOR_TOPIC_CREATION_LIMIT_BURST] |
| 2509 |
--visitor-topic-creation-limit-replenish value, --visitor_topic_creation_limit_replenish value interval at which topic-creation tokens are refilled (one per x) (default: "1m") [$NTFY_VISITOR_TOPIC_CREATION_LIMIT_REPLENISH] |
| 2510 |
--visitor-prefix-bits-ipv4 value, --visitor_prefix_bits_ipv4 value number of bits of the IPv4 address to use for rate limiting (default: 32, full address) (default: 32) [$NTFY_VISITOR_PREFIX_BITS_IPV4] |
| 2511 |
--visitor-prefix-bits-ipv6 value, --visitor_prefix_bits_ipv6 value number of bits of the IPv6 address to use for rate limiting (default: 64, /64 subnet) (default: 64) [$NTFY_VISITOR_PREFIX_BITS_IPV6] |
| 2512 |
--behind-proxy, --behind_proxy, -P if set, use forwarded header (e.g. X-Forwarded-For, X-Client-IP) to determine visitor IP address (for rate limiting) (default: false) [$NTFY_BEHIND_PROXY] |
| 2513 |
--proxy-forwarded-header value, --proxy_forwarded_header value use specified header to determine visitor IP address (for rate limiting) (default: "X-Forwarded-For") [$NTFY_PROXY_FORWARDED_HEADER] |
| 2514 |
--proxy-trusted-hosts value, --proxy_trusted_hosts value comma-separated list of trusted IP addresses, hosts, or CIDRs to remove from forwarded header [$NTFY_PROXY_TRUSTED_HOSTS] |
| 2515 |
--stripe-secret-key value, --stripe_secret_key value key used for the Stripe API communication, this enables payments [$NTFY_STRIPE_SECRET_KEY] |
| 2516 |
--stripe-webhook-key value, --stripe_webhook_key value key required to validate the authenticity of incoming webhooks from Stripe [$NTFY_STRIPE_WEBHOOK_KEY] |
| 2517 |
--billing-contact value, --billing_contact value e-mail or website to display in upgrade dialog (only if payments are enabled) [$NTFY_BILLING_CONTACT] |
| 2518 |
--enable-metrics, --enable_metrics if set, Prometheus metrics are exposed via the /metrics endpoint (default: false) [$NTFY_ENABLE_METRICS] |
| 2519 |
--metrics-listen-http value, --metrics_listen_http value ip:port used to expose the metrics endpoint (implicitly enables metrics) [$NTFY_METRICS_LISTEN_HTTP] |
| 2520 |
--profile-listen-http value, --profile_listen_http value ip:port used to expose the profiling endpoints (implicitly enables profiling) [$NTFY_PROFILE_LISTEN_HTTP] |
| 2521 |
--web-push-public-key value, --web_push_public_key value public key used for web push notifications [$NTFY_WEB_PUSH_PUBLIC_KEY] |
| 2522 |
--web-push-private-key value, --web_push_private_key value private key used for web push notifications [$NTFY_WEB_PUSH_PRIVATE_KEY] |
| 2523 |
--web-push-file value, --web_push_file value file used to store web push subscriptions [$NTFY_WEB_PUSH_FILE] |
| 2524 |
--web-push-email-address value, --web_push_email_address value e-mail address of sender, required to use browser push services [$NTFY_WEB_PUSH_EMAIL_ADDRESS] |
| 2525 |
--web-push-startup-queries value, --web_push_startup_queries value queries run when the web push database is initialized [$NTFY_WEB_PUSH_STARTUP_QUERIES] |
| 2526 |
--web-push-expiry-duration value, --web_push_expiry_duration value automatically expire unused subscriptions after this time (default: "60d") [$NTFY_WEB_PUSH_EXPIRY_DURATION] |
| 2527 |
--web-push-expiry-warning-duration value, --web_push_expiry_warning_duration value send web push warning notification after this time before expiring unused subscriptions (default: "55d") [$NTFY_WEB_PUSH_EXPIRY_WARNING_DURATION] |
| 2528 |
--help, -h |
| 2529 |
``` |