mod_auth for nagios3 and lighttpd
One has to enable mod_auth in
/etc/lighttpd/lighttpd.conf
like this
server.modules = (
"mod_access",
"mod_alias",
"mod_cgi",
"mod_accesslog",
"mod_auth",
"mod_env",
Then simply append this block - adopt the url and the backend and the user to your needs.
$HTTP["url"] =~ "/nagios3" {
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/nagios3/htpasswd.users"
auth.require = ( "" =>
(
"method" => "basic",
"realm" => "restricted area",
"require" => "user=yourusername"
)
)
setenv.add-environment = ( "REMOTE_USER" => "user" )
}
To simulate apache's mod_env we use the user mapping as to see in the last line above.
Don't forget to restart the lighty daemon gracefully.
/etc/init.d/lighttpd force-reload
Did it work for you - drop a comment.
/etc/lighttpd/lighttpd.conf
like this
server.modules = (
"mod_access",
"mod_alias",
"mod_cgi",
"mod_accesslog",
"mod_auth",
"mod_env",
Then simply append this block - adopt the url and the backend and the user to your needs.
$HTTP["url"] =~ "/nagios3" {
auth.backend = "htpasswd"
auth.backend.htpasswd.userfile = "/etc/nagios3/htpasswd.users"
auth.require = ( "" =>
(
"method" => "basic",
"realm" => "restricted area",
"require" => "user=yourusername"
)
)
setenv.add-environment = ( "REMOTE_USER" => "user" )
}
To simulate apache's mod_env we use the user mapping as to see in the last line above.
Don't forget to restart the lighty daemon gracefully.
/etc/init.d/lighttpd force-reload
Did it work for you - drop a comment.
Comments
I'm curios what parameters do you have in
alias.url?
Thanks
And here is my part of lighttpd.conf that works on Ubuntu 9.04 Server (I installed nagios from repositories, v.3.0.6-2ubuntu1.1).
$HTTP["url"] =~ "^/(nagios3/cgi-bin|cgi-bin/nagios3)" {
cgi.execute-all = "enable"
cgi.assign = ( ".cgi" => "" )
}
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" {
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" )
}
Maybe it can be simplified, but I just translated the apache2.conf that came with a package and added a little lighttpd-hack for cgi files.
I've founded before so many "false" lighttpd configs... to get mad.