Project

General

Profile

Nagios3 CGI AUTH issue

Added by majestic about 15 years ago

OS: Debian 5
Lighttpd: 1.4.19
Nagios: 3.0.6

Hi there,

I am in the middle of setting up Nagios3 on one of my servers which runs Lighttpd. I have setup Nagios with Apache without any problems in the past but for some reason I am having big trouble with the CGI authentication with lighttpd. Whats happening is this, when you goto http://domain.com/nagios, the username and password prompt pops up as expected, you type in your details and then get presented to the home page of nagios. If you click on any links on the side, it shows that you "Logged in as ?" this means you have CGI accessing errors like "It appears as though you do not have permission to view information for any of the services you requested...". This should be displaying the username you used when you first visited the site.

I think the problem is that the ENV for username is not being saved when you type it in the user/password prompt. Its ignoring it or not saving it to its veriable. I have followed http://redmine.lighttpd.net/projects/lighttpd/wiki/NagiosRecipe which has not helped.

I am enclosing my configs to see if you can spot whats wrong.

alias.url =     (
                "/cgi-bin" => "/usr/lib/cgi-bin/nagios3",
                "/nagios" => "/usr/share/nagios3/htdocs" 
                )

$HTTP["url"] =~ "^/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=simon" 
                )
        )
        setenv.add-environment = ( "REMOTE_USER" => "user" )
}

I have also tried the following:

alias.url =     (
                "/cgi-bin" => "/usr/lib/cgi-bin/nagios3",
                "/nagios" => "/usr/share/nagios3/htdocs" 
                )

$HTTP["url"] =~ "^/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" => "valid-user" 
                )
        )
        setenv.add-environment = ( "REMOTE_USER" => "valid-user" )
}

Both versions I have tried do not work.

My lighttpd server.modles config is as follows:

server.modules              = (
            "mod_setenv",
            "mod_auth",
            "mod_access",
            "mod_alias",
            "mod_accesslog",
            "mod_compress",
            "mod_fastcgi",
#           "mod_rewrite",
#           "mod_redirect",
            "mod_evhost",
            "mod_cgi",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_webdav",
#           "mod_expire",
#           "mod_flv_streaming",
#           "mod_evasive" 
)

Can anyone spot what I am doing wrong? or can tell me how I can see if its not parsing the user into server veriable?

Kind Regards,

Simon


Replies (2)

RE: Nagios3 CGI AUTH issue - Added by brainextender over 14 years ago

I ran in the same trap.

The point to resolve it is the position of

setenv.add-environment = ( "REMOTE_USER" => "user" )

in the setup.

I wrote a few lines on it on my here in my

ubuntu administrator blog1

Kind regards

brain extender

http://brainextender.blogspot.com/2009/07/modauth-for-nagios3-and-lighttpd.html

RE: Nagios3 CGI AUTH issue - Added by ckujau over 13 years ago

To make it even more clear (it wasn't to me):

  • The "user" part in setenv... has to match the nagios-user actually configured in nagios3/cgi.cfg. So, in my case it's:
  setenv.add-environment = ( "REMOTE_USER" => "nagiosadmin" )
  • setenv.add-environment has to be put in the end of the whole lighttpd configuration (check with "lighttpd -p"), otherwise it won't be honored or gets overwritten again.

However, I wonder how this will work for more than one nagios-user configured. Different URLs for each user will probably work, but it's not pretty, at all. Is this a Nagios bug? Or lighttpd's fault? Apache doesn't need this hackery, right?

    (1-2/2)