zeldor.biz

Linux, programming and more

Copyright © 2025
Log in

Nagios3 with Lighttpd

November 24, 2010 by Igor Drobot 6 Comments

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

apt-get install lighttpd


After it I install nagios3:

1
apt-get install nagios3

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

lighttpd-enable-mod

Enable modules:

1
2
3
lighttpd-enable-mod cgi
lighttpd-enable-mod auth
lighttpd-enable-mod status

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

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",
)

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

lighttpd-enable-mod php5-cgi

Now we create our own nagios3 config:

1
vim /etc/lighttpd/conf-available/10-nagios3.conf

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" )
}

# 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

lighttpd-enable-mod nagios3

If you have more than one user use pipe symbol to create more restrictions:

1
"require" => "user=nagiosadmin|user=nagiosuser"

"require" => "user=nagiosadmin|user=nagiosuser"

After restart you should reach your nagios3 service: “http://server/nagios3/”

1
/etc/init.d/lighttpd restart

/etc/init.d/lighttpd restart

Filed Under: Debian, Linux, Networking Tagged With: Lighttpd, Lighttpd and Nagios3, Lighttpd with Nagios3, Nagios3

Categories

Archives

Tags

apache2 Apple arduino ARM Automation backup bash Cisco Cluster Corosync Database Debian Debian squeeze DIY DNS Fedora FTP Fun Icinga Ipv6 KVM Linux LVM MAC OS X Monitoring MySQL Nagios Nginx openSUSE OpenVPN PHP Proxy Python python3 qemu RAID rsync Samba security ssh Ubuntu virtualization Windows Windows 7 Wordpress

Comments

  1. B says

    May 5, 2022 at 00:52

    Would be great to have an update for nagios4 and with apt install and for Raspberry…

  2. Bernd says

    October 22, 2018 at 22:34

    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.

  3. caic says

    July 20, 2014 at 10:50

    Clear and simple :)

    Thanks!

  4. Khemarin says

    September 16, 2013 at 18:10

    Very useful tutorial,
    Thank you.

  5. col says

    June 18, 2013 at 22:40

    never mind…
    htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin
    took care of it.

  6. col says

    June 18, 2013 at 22:37

    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?

Leave a Reply

Your email address will not be published. Required fields are marked *

Yeaaah Cookie! We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok