Icinga2 on lighttpd

gdm85
gdm85
Feb 14, 2016 · 2 min read

In case you are wondering if it is possible to run the awesome monitoring tool Icinga2 on lighttpd, yes it is. However it’s not as straight-forward as the other two available options (nginx, lighttpd).

Foreword: why lighttpd

Example of the disgusted face of a (potential) reader.

Fact is, nginx does not support per-vhost traffic shaping, while lighttpd does. And, guess what, almost any VPS/cloud service you will use nowadays has a hard limit for bandwidth usage, whether you think of it or not — it’s there.

To continue with the following 2 simple steps, it is assumed that you are already following the official documentation, like for example this tutorial.

Step 1: hacking the installation

apt-get install php5-fpm icinga2-ido-pgsql php5-intl php5-gd php5-imagick php5-pgsql

I am using PostgreSQL, you can replace the relevant packages with their MySQL version as desired.

A regular installation of icingaweb2 pulls in apache2, but let’s not do that, as we want a different webserver. We will instead install manually with dpkg.

#!/bin/bash
set -e
TMPD=$(mktemp -d)
cd "$TMPD"
PKGS="icingaweb2 icingaweb2-module-doc icingaweb2-module-monitoring php-icinga php5 php5-cli php5-common php5-json php5-ldap php5-readline ssl-cert"
apt-get download $PKGS
DEBS=""
for PKG in $PKGS; do DEBS=”$DEBS $PKG.deb”; done
dpkg — force-all -i *.deb
rm *deb
cd
rmdir “$TMPD”

Step 2: configure the (light) beast

Make sure that mod_fastcgi is enabled in /etc/lighttpd/lighttpd.conf, that is the only requirement for php5-fpm to work correctly in this configuration.

I suggest creating a file in /etc/lighttpd/icinga2-common.conf with this content:

server.errorlog = "/var/log/lighttpd/icinga2_error.log"
server.upload-dirs=( "/dev/null" )
server.document-root = "/usr/share/icingaweb2/public"
index-file.names = ( "index.php" )
fastcgi.server += (
".php" => ((
"socket" => "/var/run/php5-fpm.sock",
"broken-scriptfilename" => "enable"
))
)
url.rewrite-if-not-file = ( "^[^\?]+\?*(.*)$" => "/index.php?$1" )

Afterwards a file in /etc/lighttpd/conf-enabled/icinga2.conf with:

$SERVER["socket"] == "127.0.0.1:80" { # very useful
include "icinga2-common.conf"
}
$HTTP["host"] == "icinga.example.com" {
include "icinga2-common.conf"
}

And that’s all folks. You can add further customization there, like SSL etc.

Conclusion

Applied engineering reports

Random solutions for random IT problems; tastes like coffee and sweat

gdm85

Written by

gdm85

Thinker, software developer, cryptography passionate and an avid reader of science and technology.

Applied engineering reports

Random solutions for random IT problems; tastes like coffee and sweat