Password Protect Netdata and Disable Port Access in Centos Web Panel | Centos 6/7

By Bullten, In CentOS Web Panel, 0 Comments

You need to first install netdata on centos web panel then you can password protect it using the below tutorial.


Run the below command to configure netdata

sed -i '/bind to = \*/c\bind to = localhost' /usr/local/apache/htdocs/netdata/etc/netdata/netdata.conf


Generate .htpasswd file {Repalce yourusername and yourpassword}

ln -s /usr/local/apache/bin/htpasswd /usr/sbin/htpasswd
htpasswd -bc /usr/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd yourusername yourpassword


Copy and Paste all lines not one by one

cat > /usr/local/apache/conf.d/netdata-auth.conf << "EOF"
RewriteEngine On
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
Require all granted

# Local netdata server accessed with '/netdata/', at localhost:19999
ProxyPass "/netdata/" "http://localhost:19999/" connectiontimeout=5 timeout=30 keepalive=on
ProxyPassReverse "/netdata/" "http://localhost:19999/"

# if the user did not give the trailing /, add it
# for HTTP (if the virtualhost is HTTP, use this)
RewriteRule ^/netdata$ http://%{HTTP_HOST}/netdata/ [L,R=301]
# for HTTPS (if the virtualhost is HTTPS, use this)
#RewriteRule ^/netdata$ https://%{HTTP_HOST}/netdata/ [L,R=301]

<Location /netdata/>
AuthType Basic
AuthName "Protected site"
AuthUserFile /usr/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd
Require valid-user
Order deny,allow
Allow from all


Restart Apache

service netdata restart
service httpd restart


Note: Now you cant access netdata using port you need to access like http://yourserverip/netdata/