master
md 382 lines 38.3 KB
Rendered Raw
1 # Web Server Configuration Reference
2
3 You can configure Netdata's built-in web server to control how it serves dashboards, handles connections, and manages security. The web server is `static-threaded`, with a fixed, configurable number of threads.
4
5 ## Understanding the Web Server Architecture
6
7 All the threads are concurrently listening for web requests on the same sockets, and the kernel distributes the incoming requests to them. Each thread uses non-blocking I/O so it can serve any number of web requests in parallel.
8
9 It respects the `keep-alive` HTTP header to serve multiple HTTP requests via the same connection.
10
11 ## Configure Basic Settings
12
13 You can modify web server behavior by editing the `[web]` section in `netdata.conf` using the [`edit-config` script](/docs/netdata-agent/configuration/README.md#edit-configuration-files).
14
15 ### Configuration Options
16
17 | Setting | Default | Description |
18 |------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
19 | `ssl key` | `/etc/netdata/ssl/key.pem` | Declare the location of an SSL key to enable HTTPS |
20 | `ssl certificate` | `/etc/netdata/ssl/cert.pem` | Declare the location of an SSL certificate to enable HTTPS |
21 | `tls version` | `1.3` | Choose which TLS version to use. While all versions are allowed (`1` or `1.0`, `1.1`, `1.2` and `1.3`), we recommend `1.3` for the most secure encryption. If left blank, Netdata uses the highest available protocol version on your system |
22 | `tls ciphers` | `none` | Choose which TLS cipher to use. Options include `TLS_AES_256_GCM_SHA384`, `TLS_CHACHA20_POLY1305_SHA256`, and `TLS_AES_128_GCM_SHA256`. If left blank, Netdata uses the default cipher list for that protocol provided by your TLS implementation |
23 | `ses max window` | `15` | See [single exponential smoothing](/src/web/api/queries/ses/README.md) |
24 | `des max window` | `15` | See [double exponential smoothing](/src/web/api/queries/des/README.md) |
25 | `mode` | `static-threaded` | Turns on (`static-threaded`) or off (`none`) the static-threaded Web Server. See the [example](#examples) to turn off the Web Server and disable the dashboard |
26 | `listen backlog` | `4096` | The port backlog. Check `man 2 listen` |
27 | `default port` | `19999` | The listen port for the static Web Server |
28 | `web files owner` | `netdata` | The user that owns the web static files. Netdata will refuse to serve a file that is not owned by this user, even if it has read access to that file. If the user given is not found, Netdata will only serve files owned by user given in `run as user` |
29 | `web files group` | `netdata` | If this is set, Netdata will check if the file is owned by this group and refuse to serve the file if it's not |
30 | `disconnect idle clients after` | `1m` | The time in seconds to disconnect web clients after being totally idle |
31 | `timeout for first request` | `1m` | How long to wait for a client to send a request before closing the socket. Prevents slow request attacks |
32 | `accept a streaming request every` | `off` | Can be used to set a limit on how often a Parent will accept streaming requests from Children in a [streaming and replication setup](/src/streaming/README.md) |
33 | `respect do not track policy` | `no` | If set to `yes`, Netdata will respect the user's browser preferences for [Do Not Track](https://www.eff.org/issues/do-not-track) (DNT) and storing cookies. If DNT is _enabled_ in the browser, and this option is set to `yes`, nodes will not connect to any [registry](/src/registry/README.md). For certain browsers, users must disable DNT and change this option to `yes` for full functionality |
34 | `x-frame-options response header` | empty | Avoid [clickjacking attacks](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options), by ensuring that the content is not embedded into other sites |
35 | `allow connections from` | `localhost *` | Declare which IP addresses or full-qualified domain names (FQDNs) are allowed to connect to the Web Server, including the [dashboard](/docs/dashboards-and-charts/README.md) or [HTTP API](/src/web/api/README.md). This is a global setting with higher priority to any of the ones below |
36 | `allow connections by dns` | `heuristic` | See the [access list section](#access-lists) for details on using `allow` settings |
37 | `allow dashboard from` | `localhost *` | Controls dashboard and API access |
38 | `allow dashboard by dns` | `heuristic` | DNS resolution setting for dashboard access |
39 | `allow badges from` | `*` | Controls badge API access |
40 | `allow badges by dns` | `heuristic` | DNS resolution setting for badge access |
41 | `allow streaming from` | `*` | Controls metric streaming from child agents |
42 | `allow streaming by dns` | `heuristic` | DNS resolution setting for streaming access |
43 | `allow netdata.conf` | `localhost fd* 10.* 192.168.* 172.16.* 172.17.* 172.18.* 172.19.* 172.20.* 172.21.* 172.22.* 172.23.* 172.24.* 172.25.* 172.26.* 172.27.* 172.28.* 172.29.* 172.30.* 172.31.* UNKNOWN` | Controls access to configuration endpoint |
44 | `allow netdata.conf by dns` | `no` | DNS resolution setting for netdata.conf access |
45 | `allow management from` | `localhost` | Controls management API access |
46 | `allow management by dns` | `heuristic` | DNS resolution setting for management access |
47 | `enable gzip compression` | `yes` | When set to `yes`, Netdata web responses will be GZIP compressed, if the web client accepts such responses |
48 | `gzip compression strategy` | `default` | Valid settings are `default`, `filtered`, `huffman only`, `rle` and `fixed` |
49 | `gzip compression level` | `3` | Valid settings are 1 (fastest) to 9 (best ratio) |
50 | `web server threads` | auto-detected | How many processor threads the web server is allowed. The default is system-specific, the minimum of `6` or the number of CPU cores |
51 | `web server max sockets` | auto-detected | Available sockets. The default is system-specific, automatically adjusted to 50% of the max number of open files Netdata is allowed to use (via `/etc/security/limits.conf` or systemd), to allow enough file descriptors to be available for data collection |
52 | `custom dashboard_info.js` | empty | Specifies the location of a custom `dashboard.js` file. |
53
54 ## Access Lists
55
56 You can control who accesses different Netdata features using access lists in `netdata.conf`. `*` does string matches on the IPs or FQDNs of the clients.
57
58 ### Global Access Control (Applied First)
59
60 :::caution Priority Setting
61 `allow connections from` matches anyone that connects on the Netdata port(s). So, if someone is not allowed, it will be connected and disconnected immediately, without reading even a single byte from its connection. This is a global setting with higher priority to any of the ones below.
62 :::
63
64 ```text
65 [web]
66 allow connections from = localhost *
67 ```
68
69 ### Feature-Specific Access Control
70
71 Once a connection is allowed globally, these settings control access to specific features:
72
73 - **`allow dashboard from`** - receives the request and examines if it is a static dashboard file or an API call the dashboards do.
74
75 - **`allow badges from`** - checks if the API request is for a badge. Badges aren't matched by `allow dashboard from`.
76
77 - **`allow streaming from`** - checks if the child willing to stream metrics to this Netdata is allowed. This can be controlled per API KEY and MACHINE GUID in `stream.conf`. The setting in `netdata.conf` is checked before the ones in `stream.conf`.
78
79 - **`allow netdata.conf from`** - checks the IP to allow `http://netdata.host:19999/netdata.conf`. The IPs listed are all the private IPv4 addresses, including link-local IPv6 addresses. Keep in mind that connections to Netdata API ports are filtered by `allow connections from`. So, IPs allowed by `allow netdata.conf from` should also be allowed by `allow connections from`.
80
81 - **`allow management from`** - checks the IPs to allow API management calls. Management via the API is currently supported for [health](/src/web/api/health/README.md#health-management-api)
82
83 ### Common Configuration Examples
84
85 ```text
86 # Allow only local access
87 [web]
88 allow connections from = localhost
89 allow dashboard from = localhost
90 allow management from = localhost
91 ```
92
93 ```text
94 # Allow private network access
95 [web]
96 allow connections from = localhost 10.* 192.168.*
97 allow dashboard from = localhost 10.* 192.168.*
98 allow badges from = *
99 allow streaming from = *
100 allow management from = localhost
101 ```
102
103 <details>
104 <summary><strong>Advanced: DNS Resolution Settings</strong></summary>
105
106 To check the FQDN of the connection without opening the Netdata Agent to DNS-spoofing, a reverse-dns record must be setup for the connecting host. At connection time, the reverse-dns of the peer IP address is resolved, and a forward DNS resolution is made to validate the IP address against the name-pattern.
107
108 :::note
109
110 This process can be expensive on a machine that is serving many connections. Each access list has an associated configuration option to turn off DNS-based patterns completely to avoid incurring this cost at run-time:
111
112 :::
113
114 ```text
115 allow connections by dns = heuristic
116 allow dashboard by dns = heuristic
117 allow badges by dns = heuristic
118 allow streaming by dns = heuristic
119 allow netdata.conf by dns = no
120 allow management by dns = heuristic
121 ```
122
123 The three possible values for each of these options are `yes`, `no` and `heuristic`. The `heuristic` option disables the check when the pattern only contains IPv4/IPv6 addresses or `localhost`, and enables it when wildcards are present that may match DNS FQDNs.
124
125 </details>
126
127 ## DDoS Protection
128
129 If you publish your Netdata web server to the internet, you may want to apply some protection against DDoS:
130
131 1. Use the `static-threaded` web server (it is the default)
132 2. Use reasonable `[web].web server max sockets` (e.g default)
133 3. Don't use all your CPU cores for Netdata (lower `[web].web server threads`)
134 4. Run the `netdata` process with a low process scheduling priority (the default is the lowest)
135 5. If possible, proxy Netdata via a full-featured web server (Nginx, Apache, etc.)
136
137 ## Examples
138
139 <details>
140 <summary><strong>Disable the Web Server</strong></summary>
141
142 Edit the `[web]` section in `netdata.conf` (see [Configure Basic Settings](#configure-basic-settings) for edit-config usage):
143
144 ```text
145 [web]
146 mode = none
147 ```
148
149 Restart your Agent to apply changes. After restart, the Agent's web server (default port `19999`) will no longer accept inbound connections.
150
151
152 :::warning
153
154 This disables inbound connections, including streams from Child Agents.
155 **Do not use this setting on Parent Agents.**
156
157 :::
158
159 </details>
160
161 <details>
162 <summary><strong>Change the Number of Threads</strong></summary>
163
164 Control the number of threads and sockets with the following settings:
165
166 ```text
167 [web]
168 web server threads = 4
169 web server max sockets = 512
170 ```
171
172 </details>
173
174 <details>
175 <summary><strong>Change the Default Port</strong></summary>
176
177 By default, the Netdata web server listens on port `19999`. To change the default port, edit the `[web]` section in `netdata.conf` (see [Configure Basic Settings](#configure-basic-settings) for edit-config usage):
178
179 ```text
180 [web]
181 default port = 8000
182 ```
183
184 If you have configured `[web].bind to` with explicit ports, you must also update those explicit port numbers, or remove the port portion so the entries fall back to using `default port`.
185 After modifying the configuration, restart the Netdata service to apply changes. See the [service control documentation](/docs/netdata-agent/start-stop-restart.md) for instructions.
186
187 </details>
188
189 <details>
190 <summary><strong>Binding Netdata to Multiple Ports</strong></summary>
191
192 Netdata can bind to multiple IPs and ports, offering access to different services on each. Up to 100 sockets can be used (increase it at compile time with `CFLAGS="-DMAX_LISTEN_FDS=200" ./netdata-installer.sh ...`).
193
194 The ports to bind are controlled via `[web].bind to`, like this:
195
196 ```text
197 [web]
198 default port = 19999
199 bind to = 127.0.0.1=dashboard^SSL=optional 10.1.1.1:19998=management|netdata.conf hostname:19997=badges [::]:19996=streaming^SSL=force localhost:19995=registry *:http=dashboard unix:/run/netdata/netdata.sock
200 ```
201
202 Using the above, Netdata will bind to:
203
204 - IPv4 127.0.0.1 at port 19999 (port was used from `default port`). Only the UI (dashboard) and the read API will be accessible on this port. Both HTTP and HTTPS requests will be accepted.
205 - IPv4 10.1.1.1 at port 19998. The management API and `netdata.conf` will be accessible on this port.
206 - All the IPs `hostname` resolves to (both IPv4 and IPv6 depending on the resolved IPs) at port 19997. Only badges will be accessible on this port.
207 - All IPv6 IPs at port 19996. Only metric streaming requests from other Netdata Agents will be accepted on this port. Only encrypted streams will be allowed (i.e., Children also need to be [configured for TLS](/src/streaming/README.md)).
208 - All the IPs `localhost` resolves to (both IPv4 and IPv6 depending on the resolved IPs) at port 19995. This port will only accept registry API requests.
209 - All IPv4 and IPv6 IPs at port `http` as set in `/etc/services`. Only the UI (dashboard) and the read API will be accessible on this port.
210 - Unix domain socket `/run/netdata/netdata.sock`. All requests are serviceable on this socket. Note that in some OSs like Fedora, every service sees a different `/tmp`, so don't create a Unix socket under `/tmp`. `/run` or `/var/run` is suggested.
211
212 The option `[web].default port` is used when entries in `[web].bind to` do not specify a port.
213
214 As shown in the example above, these permissions are optional, with the default permitting all request types on the specified port.
215
216 The request types are strings identical to the `allow X from` directives of the access lists, i.e. `dashboard`, `streaming`, `registry`, `netdata.conf`, `badges` and `management`. The access lists themselves and the general setting `allow connections from` in the next section are applied regardless of the ports that are configured to provide these services.
217
218 The API requests are serviced as follows:
219
220 - `dashboard` gives access to the UI, the read API and badges API calls.
221 - `badges` gives access only to the badge API calls.
222 - `management` gives access only to the management API calls.
223
224 </details>
225
226 <details>
227 <summary><strong>Enable HTTPS/TLS Support</strong></summary>
228
229 Since v1.16.0, Netdata supports encrypted HTTP connections to the web server, plus encryption of streaming data to a parent from its child nodes, via the TLS protocol.
230
231 Inbound unix socket connections are unaffected, regardless of the TLS settings.
232
233 :::tip SSL vs TLS Terminology
234 While Netdata uses Transport Layer Security (TLS) 1.2 to encrypt communications rather than the obsolete SSL protocol, it's still common practice to refer to encrypted web connections as `SSL`. Many vendors, like Nginx and even Netdata itself, use `SSL` in configuration files, whereas documentation will always refer to encrypted communications as `TLS` or `TLS/SSL`.
235 :::
236
237 To enable TLS, provide the path to your certificate and private key in the `[web]` section of `netdata.conf`:
238
239 ```text
240 [web]
241 ssl key = /etc/netdata/ssl/key.pem
242 ssl certificate = /etc/netdata/ssl/cert.pem
243 ```
244
245 Both files must be readable by the `netdata` user. If any of these files are missing or can't be read, Netdata will fall back to using HTTP. For a parent-child connection, only the parent needs these settings.
246
247 For test purposes, generate self-signed certificates with the following command:
248
249 ```bash
250 openssl req -newkey rsa:2048 -nodes -sha512 -x509 -days 365 -keyout key.pem -out cert.pem
251 ```
252
253 :::tip Certificate Performance
254 If you use 4096 bits for your key and the certificate, Netdata will need more CPU to process the communication. `rsa4096` can be up to four times slower than `rsa2048`, so we recommend using 2048 bits. Verify the difference by running:
255
256 ```bash
257 openssl speed rsa2048 rsa4096
258 ```
259
260 :::
261
262 ### Obtaining TLS Certificates
263
264 Self-signed certificates are suitable for testing and development environments. For production deployments, you should obtain certificates from a trusted Certificate Authority (CA) to ensure proper security and avoid browser warnings.
265
266 #### Certificate Acquisition Options
267
268 1. **Let's Encrypt (Recommended for public-facing instances)**
269 - Free, automated certificate authority
270 - For HTTP-01/TLS-ALPN-01, requires public DNS plus inbound ports 80/443, or use DNS-01 if those ports aren’t available
271 - Certificates auto-renew with proper configuration
272 - Install using [Certbot](https://certbot.eff.org/) or other ACME clients
273 - Certificates are issued in PEM format, compatible with Netdata
274
275 2. **Commercial Certificate Authorities**
276 - Paid certificates from providers like DigiCert, Comodo, or GlobalSign
277 - Various validation levels (DV, OV, EV) available
278 - Suitable for organizations requiring extended validation
279 - Ensure certificates are provided in PEM format or convert them
280
281 3. **Internal Certificate Authorities**
282 - For enterprise environments with private PKI infrastructure
283 - Allows complete control over certificate lifecycle
284 - See [Using custom CA certificates with Netdata](/docs/netdata-agent/configuration/using-custom-ca-certificates-with-netdata.md) for configuration details
285 - Requires clients to trust your internal CA
286
287 #### Netdata Certificate Requirements
288
289 Regardless of the source, ensure your certificates meet these requirements:
290
291 - **Format**: PEM format (most common format, used by Let's Encrypt and compatible with OpenSSL)
292 - **Full chain**: For CA-issued certificates, `ssl certificate` must include all intermediate certificates to avoid browser warnings. Let's Encrypt issues `fullchain.pem` (certificate + intermediates) and `privkey.pem` (private key) — use these directly.
293 - **Location**: Place certificates in `/etc/netdata/ssl/` or another secure directory
294 - **Permissions**: Certificate and key files must be readable by the `netdata` user
295 - **Paths**: Configure the paths in `netdata.conf`:
296
297 ```text
298 [web]
299 ssl key = /etc/netdata/ssl/privkey.pem
300 ssl certificate = /etc/netdata/ssl/fullchain.pem
301 ```
302
303 </details>
304
305 <details>
306 <summary><strong>Select TLS Version</strong></summary>
307
308 Beginning with version `v1.21.0`, specify the TLS version and the ciphers that you want to use:
309
310 ```text
311 [web]
312 tls version = 1.3
313 tls ciphers = TLS_AES_256_GCM_SHA384:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_128_GCM_SHA256
314 ```
315
316 If you don't specify these options, Netdata will use the highest available protocol version on your system and the default cipher list for that protocol provided by your TLS implementation.
317
318 ### TLS/SSL Enforcement
319
320 When the certificates are defined and unless any other options are provided, a Netdata server will:
321
322 - Redirect all incoming HTTP web server requests to HTTPS. Applies to the dashboard, the API, `netdata.conf` and badges.
323 - Allow incoming child connections to use both unencrypted and encrypted communications for streaming.
324
325 To change this behavior, you need to modify the `bind to` setting in the `[web]` section of `netdata.conf`. At the end of each port definition, append `^SSL=force` or `^SSL=optional`. What happens with these settings differs, depending on whether the port is used for HTTP/S requests or for streaming.
326
327 | SSL setting | HTTP requests | HTTPS requests | Unencrypted Streams | Encrypted Streams |
328 |:-----------:|:-------------------:|:--------------:|:-------------------:|:------------------|
329 | none | Redirected to HTTPS | Accepted | Accepted | Accepted |
330 | `force` | Redirected to HTTPS | Accepted | Denied | Accepted |
331 | `optional` | Accepted | Accepted | Accepted | Accepted |
332
333 Example:
334
335 ```text
336 [web]
337 bind to = *=dashboard|registry|badges|management|streaming|netdata.conf^SSL=force
338 ```
339
340 For information how to configure the child to use TLS, check [securing the communication](/src/streaming/README.md#secure-communications) in the streaming documentation. There you will find additional details on the expected behavior for client and server nodes, when their respective TLS options are enabled.
341
342 When we define the use of SSL in a Netdata Agent for different ports, Netdata will apply the behavior specified on each port. For example, using the configuration line below:
343
344 ```text
345 [web]
346 bind to = *=dashboard|registry|badges|management|streaming|netdata.conf^SSL=force *:20000=netdata.conf^SSL=optional *:20001=dashboard|registry
347 ```
348
349 Netdata will:
350
351 - Force all HTTP requests to the default port to be redirected to HTTPS (same port).
352 - Refuse unencrypted streaming connections from child nodes on the default port.
353 - Allow both HTTP and HTTPS requests to port 20000 for `netdata.conf`
354 - Force HTTP requests to port 20001 to be redirected to HTTPS (same port). Only allow requests for the dashboard, the read API and the Registry on port 20001.
355
356 ### TLS/SSL Errors
357
358 When you start using Netdata with TLS, you may find errors in the Netdata log, which is stored at `/var/log/netdata/error.log` by default.
359
360 Most of the time, these errors are due to incompatibilities between your browser's options related to TLS/SSL protocols and Netdata's internal configuration. The most common error is `error:00000006:lib(0):func(0):EVP lib`.
361
362 </details>
363
364 <details>
365 <summary><strong>WebSocket Support</strong></summary>
366
367 Netdata supports WebSocket connections for real-time data streaming and interactive features. For detailed information on WebSocket protocols, configuration options, and examples, see the [WebSocket documentation](/src/web/websocket/README.md).
368
369 ### WebSocket Frame Size Configuration
370
371 Netdata automatically fragments large WebSocket messages to ensure browser compatibility. The default maximum outgoing frame size is 4MB, which works well for most browsers.
372
373 For clients with specific requirements, you can customize the maximum frame size on a per-connection basis by adding the `max_frame_size` parameter to the WebSocket URL:
374
375 ```
376 ws://localhost:19999/echo?max_frame_size=32768
377 ```
378
379 This is particularly useful for resource-constrained devices or network environments with specific limitations.
380
381 </details>
382