Score:0

Debian 11, Nagios4, and 403 forbidden

cn flag

Having installed Debian's Nagios4 package I can't access it. Apache gives me this:

AH01797: client denied by server configuration: /usr/share/nagios4/htdocs

I've tried various things, such as changing ownership of the relevant directories to the www-data user & group (apache2 is running as this user), and editing config files to add the permission for that directory:

/etc/apache2/conf-available/nagios4-cgi.conf

...
<Directory /usr/share/nagios4/htdocs>
    Options     +ExecCGI        
    Order allow,deny
    Require all granted
</Directory>
...

/etc/apache2/sites-enabled/

ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
ScriptAlias /nagios4/cgi-bin /usr/lib/cgi-bin/nagios4
Alias /nagios4/stylesheets /etc/nagios4/stylesheets
Alias /nagios4 /usr/share/nagios4/htdocs
<DirectoryMatch (/usr/share/nagios4/htdocs|/usr/lib/cgi-bin/nagios4|/etc/nagios4/stylesheets)>
    Options FollowSymLinks
    DirectoryIndex index.php index.html
    AllowOverride AuthConfig
    #Require ip ::1/128 fc00::/7 fe80::/10 10.0.0.0/8 127.0.0.0/8 169.254.0.0/16 172.16.0.0/12 192.168.0.0/16
    <Files "cmd.cgi">
        AuthDigestDomain "Nagios4"
        AuthDigestProvider file
        AuthUserFile    "/etc/nagios4/htdigest.users"
        AuthGroupFile   "/etc/group"
        AuthName        "Nagios4"
        AuthType        Digest
        Require all     granted
    </Files>
</DirectoryMatch>
<Directory /usr/share/nagios4/htdocs>
    Options     +ExecCGI        
    Order allow,deny
    AllowOverride All
    Require all granted
</Directory>

Can anyone think of anything I've missed?

in flag
Both `<DirectoryMatch>` and `<Directory>` directives match the path `/usr/share/nagios4/htdocs`. Apache will only use one of these.
in flag
Apart from that you are mixing Apache 2.2 and 2.4 directives, [which is discouraged](https://httpd.apache.org/docs/2.4/upgrading.html#run-time) because it leads to possible problems. Your Apache should be 2.4, so you should remove the old 2.2 directives.
knirirr avatar
cn flag
Good point about the mixed directives. I have tried removing /usr/share/nagios4/htdocs from the DirectoryMatch line (though this file was otherwise as the default) with no change.
Score:-1
cn flag

The eventual answer was to move instructions from the Directory block into the DirectoryMatch block, in particular Require all granted.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.