2019-09-09 05:48:35 -05:00
|
|
|
# Securing with nginx
|
|
|
|
|
2018-10-27 23:04:34 +01:00
|
|
|
path: blob/master/doc/
|
2016-11-30 15:21:17 -08:00
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
According to the [man page](https://linux.die.net/man/1/rrdcached),
|
|
|
|
under "SECURITY CONSIDERATIONS", rrdcached has no authentication or
|
|
|
|
security except for running under a unix socket. If you choose to use
|
|
|
|
a network socket instead of a unix socket, you will need to secure
|
|
|
|
your rrdcached installation. To do so you can proxy rrdcached using
|
|
|
|
nginx to allow only specific IPs to connect.
|
|
|
|
|
|
|
|
Using the same setup above, using nginx version 1.9.0 or later, you
|
|
|
|
can follow this setup to proxy the default rrdcached port to the local
|
|
|
|
unix socket.
|
2016-11-30 15:21:17 -08:00
|
|
|
|
|
|
|
(You can use `./conf.d` for your configuration as well)
|
|
|
|
|
|
|
|
`mkdir /etc/nginx/streams-{available,enabled}`
|
|
|
|
|
|
|
|
add the following to your nginx.conf file:
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2016-11-30 15:21:17 -08:00
|
|
|
```nginx
|
|
|
|
#/etc/nginx/nginx.conf
|
|
|
|
...
|
|
|
|
stream {
|
|
|
|
include /etc/nginx/streams-enabled/*;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2019-09-09 05:48:35 -05:00
|
|
|
Add this to `/etc/nginx/streams-available/rrd`
|
|
|
|
|
2016-11-30 15:21:17 -08:00
|
|
|
```nginx
|
|
|
|
server {
|
|
|
|
listen 42217;
|
|
|
|
|
|
|
|
error_log /var/log/nginx/rrd.stream.error.log;
|
|
|
|
|
|
|
|
allow $LibreNMS_IP;
|
|
|
|
deny all;
|
|
|
|
|
|
|
|
proxy_pass unix:/var/run/rrdcached/rrdcached.sock;
|
|
|
|
}
|
2019-09-09 05:48:35 -05:00
|
|
|
|
2016-11-30 15:21:17 -08:00
|
|
|
```
|
2019-09-09 05:48:35 -05:00
|
|
|
|
|
|
|
Replace `$LibreNMS_IP` with the ip of the server that will be using
|
|
|
|
rrdcached. You can specify more than one `allow` statement. This will
|
|
|
|
bind nginx to TCP 42217 (the default rrdcached port), allow the
|
|
|
|
specified IPs to connect, and deny all others.
|
2016-11-30 15:21:17 -08:00
|
|
|
|
|
|
|
next, we'll symlink the config to streams-enabled:
|
|
|
|
`ln -s /etc/nginx/streams-{available,enabled}/rrd`
|
|
|
|
|
|
|
|
and reload nginx
|
|
|
|
`service nginx reload`
|