Why I do it?
Cause my Nagios3 is running as a virtual machine on a Xen Server, and I have less than 64MB of RAM.
First I install lighttpd, to prevent automatically apache2 installation during the nagios3 installation:
1 | apt-get install lighttpd |
After it I install nagios3:
1 | apt-get install nagios3 |
To use Nagios3 we need following modules:
- mod_cgi
- mod_auth
- mod_setenv
Just run lighttpd-enable-mod to enable available modules (you will see all available):
1 | lighttpd-enable-mod |
Enable modules:
1 2 3 | lighttpd-enable-mod cgi lighttpd-enable-mod auth lighttpd-enable-mod status |
To use nagios we need PHP support – install php5-cgi:
1 | apt-get install php5-cgi |
To run php applications we need to set a php path:
1 2 3 4 5 | vim /etc/lighttpd/conf-available/10-php5-cgi.conf # content cgi.assign += ( ".php" => "/usr/bin/php5-cgi", ) |
And enable it:
1 | lighttpd-enable-mod php5-cgi |
Now we create our own nagios3 config:
1 | vim /etc/lighttpd/conf-available/10-nagios3.conf |
This is the content of it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | # Nagios3 alias.url = ( "/cgi-bin/nagios3" => "/usr/lib/cgi-bin/nagios3", "/nagios3/cgi-bin" => "/usr/lib/cgi-bin/nagios3", "/nagios3/stylesheets" => "/etc/nagios3/stylesheets", "/nagios3" => "/usr/share/nagios3/htdocs" ) $HTTP["url"] =~ "^/nagios3/cgi-bin" { cgi.assign = ( "" => "" ) } $HTTP["url"] =~ "nagios" { auth.backend = "htpasswd" auth.backend.htpasswd.userfile = "/etc/nagios3/htpasswd.users" auth.require = ( "" => ( "method" => "basic", "realm" => "nagios", "require" => "user=nagiosadmin" ) ) setenv.add-environment = ( "REMOTE_USER" => "user" ) } |
Enable created module:
1 | lighttpd-enable-mod nagios3 |
If you have more than one user use pipe symbol to create more restrictions:
1 | "require" => "user=nagiosadmin|user=nagiosuser" |
After restart you should reach your nagios3 service: “http://server/nagios3/”
1 | /etc/init.d/lighttpd restart |
B says
Would be great to have an update for nagios4 and with apt install and for Raspberry…
Bernd says
Installing nagios3 on lighttpd (on Raspbian / pi.hole) in October 2018:
It took me some hours to figure out that the line
“setenv.add-environment = ( “REMOTE_USER” => “[whatever]” )”
actually BREAKS nagios, leaving various messages like “you don’t have access rights to CGI” when trying to see data on the web interface. I removed this line and everything works now.
caic says
Clear and simple :)
Thanks!
Khemarin says
Very useful tutorial,
Thank you.
col says
never mind…
htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
took care of it.
col says
very helpful…thank you.
got it set up but when i installed it (debian…actually raspbian) i wasn’t asked for a password…now i can’t log in. any ideas?