Resources monitor per user/website

Started by ring_c, September 01, 2018, 08:54:37 PM

Previous topic - Next topic

Rug3r

Quote from: bullten on September 03, 2018, 11:28:47 AM

Did you try to run the following command for permission

chown -R netdata:netdata /usr/local/apache/htdocs/netdata

Thanks for the fix Bullten

ring_c


bullten

Well you can password protect it like below
Quote
nano  /usr/local/apache/htdocs/netdata/etc/netdata/netdata.conf

Find # bind to = under [web] and uncomment it and change it to bind to = localhost

Before

Quote[web]
        # mode = static-threaded
        # listen backlog = 4096
        # default port = 19999
        # bind to =
        # web files owner = netdata
        # web files group = netdata

After   
   
Quote[web]
        # mode = static-threaded
        # listen backlog = 4096
        # default port = 19999
        bind to = localhost
        # web files owner = netdata
        # web files group = netdata


Create Password


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

Quotecat > /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/local/apache/htdocs/netdata/usr/share/netdata/web/.htpasswd
      Require valid-user
      Order deny,allow
      Allow from all
</Location>
   
</VirtualHost>
EOF

Restart Apache
service httpd restart

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

ring_c

Quote from: bullten on September 03, 2018, 02:13:17 PM
Create Password

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



First, thank you so much for all your help.
Second, I got the following error:



[root@cwp ~]# ln -s /usr/local/apache/bin/htpasswd /usr/sbin/htpasswd
ln: failed to create symbolic link '/usr/sbin/htpasswd': File exists



bullten

Its just a warning to let you know file already exist there. You dont need to worry about that. I would suggest you to follow this tutorial

https://blog.bullten.com/centos-web-panel/password-protect-netdata-and-disable-port-access-in-centos-web-panel-centos-6-7/

Rug3r

Quote from: bullten on September 03, 2018, 09:23:32 PM
Its just a warning to let you know file already exist there. You dont need to worry about that. I would suggest you to follow this tutorial

https://blog.bullten.com/centos-web-panel/password-protect-netdata-and-disable-port-access-in-centos-web-panel-centos-6-7/

Hey Bullten,

I followed all on your write up for adding password protection and it all worked fine except for some reason I had to use chown -R netdata:netdata /usr/local/apache/htdocs/netdata again to access it after filling in user and password. I had to use chown -R netdata:netdata /usr/local/apache/htdocs/netdata yesterday in order to access netdata. What would cause me to have to do it today?

Or is this fixed now that I added password protection?

Thanks, Rug3r

bullten

nano /usr/local/apache/htdocs/netdata/etc/netdata/netdata.conf

Find

Quote# run as user = netdata
# web files owner = netdata
# web files group = netdata

Uncomment them

Quoterun as user = netdata
web files owner = netdata
web files group = netdata

Save and restart netdata

service netdata restart

See if its happening now.

Sandeep

Quote from: ring_c on September 03, 2018, 12:41:08 PM
Correct. I will have to investigate how to do it. As a newbie, everything looks so difficult (throws me back to the MS-DOS days before the Windows era, but I haven't used command line ever since)...


Any chance you have a guide up your sleeve to share how to put this password protection in place?
https://github.com/firehol/netdata/wiki/Running-behind-nginx#enable-authentication

ring_c

Quote from: Sandeep on September 05, 2018, 01:01:04 PM
https://github.com/firehol/netdata/wiki/Running-behind-nginx#enable-authentication
I only managed to break my nginx when adding things to nginx.conf :(
As I can't password protect it, I think I'll have to uninstall it unfortunately...