Netdata is a free, open-source and real-time performance and health monitoring tool. It supports Linux, MacOS and FreeBSD. You can troubleshoot and monitor cloud-based servers, containers and your entire IT infrastructure with Netdata. It provides real-time system metrics including, Memory usage, CPU, Bandwidth, Disk utilization and more. You can also integrate it with other monitoring tools like Prometheus, Graphite, OpenTSDB, Kafka, Grafana, and more.

In this tutorial, we will show you how to install the Netdata monitoring tool and password protect it with Nginx.

1) Let's Begin by updating our system:

CentOS:

yum -y update

Debian/Ubuntu:

apt -y update

2) Installing NetData:

bash <(curl -Ss https://my-netdata.io/kickstart.sh)

3) Let's install the additional tools we need:

CentOS:

yum -y install httpd-tools nginxyum -y update

Debian/Ubuntu:

apt -y install apache2-utils nginx

 

4) We will now edit NetData configuration file and configure it to listen locally only. Later we will use Nginx as reverse proxy to access it:

nano /etc/netdata/netdata.conf

Under the [web] section find:
#bind to = *
Uncomment it and replace it with:
bind to = 127.0.0.1
And finally restart netdata:
systemctl restart netdata

5) Let's setup Nginx:

nano /etc/nginx/conf.d/netdata.conf
Copy and paste the following code:

upstream backend {
# the Netdata server
server 127.0.0.1:19999;
keepalive 64;
}

server {
# nginx listens to this
listen 12345;

# the virtual host name of this
server_name 10.10.10.10;
auth_basic "Administrator's Area";
auth_basic_user_file /etc/.htpasswd;


location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://backend;
proxy_http_version 1.1;
proxy_pass_request_headers on;
proxy_set_header Connection "keep-alive";
proxy_store off;
}
}

Make sure you replace listen 12345; with your desired port number and 10.10.10.10 with your actual server IP address.
With the above code we have configured Nginx with basic authentication.

 

6) Let's add username and password:

htpasswd -c /etc/.htpasswd NetDataAdmin
systemctl restart nginx

 

7) Finally we might need to allow port 12345, or whichever port you setup, through our firewall:

CentOS:

firewall-cmd --add-port=12345/tcp --permanent;firewall-cmd --reload

Debian/Ubuntu:

sudo ufw allow from any to any port 12345 proto tcp

8) Let's reboot our server and test:

reboot

Once your server comes back online you should be able to access your Netdata by visiting http://Your-Server-IP:12345 in browser and login with username: NetDataAdmin and the password you created.

Je li Vam ovaj odgovor pomogao? 2231 Korisnici koji smatraju članak korisnim (2259 Glasovi)