passwd

-----

Password Protect Netdata &  Disable Port Access on Centos Web Panel - Centos 6/7

# sed -i '/bind to = \*/c\bind to = localhost' /etc/netdata/netdata.conf

vi /etc/netdata/netdata.conf

Line no: # remove

45      run as user = netdata

62      bind to = localhost

63      web files owner = netdata

64      web files group = netdata

# ln -s /usr/bin/htpasswd /usr/sbin/htpasswd

# htpasswd -bc /usr/share/netdata/web/htpasswd admin passwdStrong 

# chown -R netdata:netdata /usr/share/netdata/web/

[root@ns ~]# vi /etc/httpd/conf.d/netdata-auth.conf           #[ Add this Line ]

                            ------------------------------------------------------------------

 <VirtualHost *:80>

       RewriteEngine On

       ProxyRequests Off

       ProxyPreserveHost On

   <Proxy *>

      Require all granted

   </Proxy>

# 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/share/netdata/web/htpasswd

      Require valid-user

      Order deny,allow

      Allow from all

      ExpiresActive On

      ExpiresDefault M310

 </Location>

 </VirtualHost>

               ----------------------------------------------------------

systemctl restart netdata

systemctl restart httpd

                                           OR --- Copy and Paste all lines not one by one

                                  -----------------------------------------------------------

cat > /usr/local/apache/conf.d/netdata-auth.conf << "EOF"

<VirtualHost *:80>

       RewriteEngine On

       ProxyRequests Off

       ProxyPreserveHost On

   <Proxy *>

      Require all granted

   </Proxy>

# 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/share/netdata/web/htpasswd

      Require valid-user

      Order deny,allow

      Allow from all

      ExpiresActive On

      ExpiresDefault M310

 </Location>

 </VirtualHost>

EOF

         -----------------X----------------------

systemctl restart netdata

systemctl restart httpd

----------