Page 1 of 1

Nagios Web Interface Downloading PHP File

Posted: Thu Feb 14, 2019 10:15 am
by HarmlessSaucer
Hey,
I'm in the middle of trying to setup Nagios on a Monsoon VM (RHEL 7.6) and I'm running into some issues.
We don't have complete access to the system, so I've had to modify the steps in the installation guide slightly. We have su access, but I'm not able to create a "nagios" user, so I'm running everything under the user we have setup. (I'm wondering if that's the issue).

However, where I'm at now, is that Nagios runs without any errors, and I can visit the <IPAddress>/nagios but I Safari/Chrome etc. downloads a file (which looks like the contents of index.php, but gets the filename 'download') instead of displaying the web interface.

Conf:

Code: Select all

ScriptAlias /nagios/cgi-bin /useraccount/nagios/sbin/

<Directory /useraccount/nagios/sbin/>
#  SSLRequireSSL
   Options All
   AllowOverride All
   <IfVersion >= 2.3>
      <RequireAll>
         Require all granted
#        Require host 127.0.0.1

         AuthName "Nagios Access"
         AuthType Basic
         AuthUserFile /useraccount/nagios/etc/htpasswd.users
         Require valid-user
      </RequireAll>
   </IfVersion>
   <IfVersion < 2.3>
      Order allow,deny
      Allow from all
#     Order deny,allow
#     Deny from all
#     Allow from 127.0.0.1

      AuthName "Nagios Access"
      AuthType Basic
      AuthUserFile /useraccount/nagios/etc/htpasswd.users
      Require valid-user
   </IfVersion>
</Directory>

Alias /nagios/ /useraccount/nagios/share/

<Directory /useraccount/nagios/share/>
#  SSLRequireSSL
   Options All
   AllowOverride All
   <IfVersion >= 2.3>
      <RequireAll>
         Require all granted
#        Require host 127.0.0.1

         AuthName "Nagios Access"
         AuthType Basic
         AuthUserFile /useraccount/nagios/etc/htpasswd.users
         Require valid-user
      </RequireAll>
   </IfVersion>
   <IfVersion < 2.3>
      Order allow,deny
      Allow from all
#     Order deny,allow
#     Deny from all
#     Allow from 127.0.0.1

      AuthName "Nagios Access"
      AuthType Basic
      AuthUserFile /useraccount/nagios/etc/htpasswd.users
      Require valid-user
   </IfVersion>
</Directory>

In httpd.conf it has the modules setup:

Code: Select all

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cgi_module /etc/httpd/modules/mod_cgi.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php7_module        modules/libphp7.so
I thought this could be a CGI problem, but it looks like it's running:

Code: Select all

./httpd -M
Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 alias_module (shared)
 rewrite_module (shared)
 php7_module (shared)

Re: Nagios Web Interface Downloading PHP File

Posted: Thu Feb 14, 2019 11:28 am
by mcapra
What steps/documentation did you use to install Nagios Core? Here is the official documentation, which is recommended:
https://support.nagios.com/kb/article/n ... ource.html

I'd switch the Options directive under the /useraccount/nagios/sbin/ Directory from All to just ExecCGI for starters, as that is what make will use by default post-configure:
https://github.com/NagiosEnterprises/na ... onf.in#L12

Re: Nagios Web Interface Downloading PHP File

Posted: Thu Feb 14, 2019 4:09 pm
by scottwilkerson
Thanks @mcapra

Re: Nagios Web Interface Downloading PHP File

Posted: Wed Feb 20, 2019 10:28 am
by HarmlessSaucer
Thanks for the replies guys.
I followed the standard guide but was having to modify some folders.
In the end it ended up being an issue with a line in httpd.conf being commented out meaning PHP wasn’t working correctly. So that’s my bad! All working great now!

Thanks for the pointers tho!