Page 1 of 3

CGI Downloading Instead of Executing

Posted: Thu May 29, 2014 12:50 pm
by rbalabama
Following the Ubuntu quickstart guide for Nagios4 I have installed Nagios 4.06 on Ubuntu 14.04 and it is running (the nagios service). I can get to the default Nagios web page, however when I click on a link the browser downloads the file instead of executing the script. I have populated the following into the apache2.conf file and made sure the paths aligned. I have read many posts, and Apache2 CGI tutorial, however I still cannot figure it out. Any help is appreciated. Thanks

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"

<Directory "/usr/local/nagios/sbin">
# SSLRequireSSL
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options
AllowOverride None
Order allow,deny
Allow from all
# Order deny,allow
# Deny from all
# Allow from 127.0.0.1
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Re: CGI Downloading Instead of Executing

Posted: Thu May 29, 2014 1:47 pm
by abrist
Are the cgis executable?

Code: Select all

ls -la /usr/local/nagios/sbin
Is the cgi module loaded with apache:

Code: Select all

httpd -M | grep cgi

Re: CGI Downloading Instead of Executing

Posted: Fri May 30, 2014 5:20 am
by rbalabama
All of the cgi's in the sbin folder are executable.
root@logstash141:/home/rb# ls -la /usr/local/nagios/sbin
total 5136
drwxrwxr-x 2 nagios nagios 4096 May 28 10:33 .
drwxr-xr-x 9 root root 4096 May 28 10:40 ..
-rwxrwxr-x 1 nagios nagios 316480 May 28 10:33 archivejson.cgi
-rwxrwxr-x 1 nagios nagios 301920 May 28 10:33 avail.cgi
-rwxrwxr-x 1 nagios nagios 300336 May 28 10:33 cmd.cgi
-rwxrwxr-x 1 nagios nagios 273176 May 28 10:33 config.cgi
-rwxrwxr-x 1 nagios nagios 314176 May 28 10:33 extinfo.cgi
-rwxrwxr-x 1 nagios nagios 265168 May 28 10:33 histogram.cgi
-rwxrwxr-x 1 nagios nagios 244552 May 28 10:33 history.cgi
-rwxrwxr-x 1 nagios nagios 240440 May 28 10:33 notifications.cgi
-rwxrwxr-x 1 nagios nagios 318272 May 28 10:33 objectjson.cgi
-rwxrwxr-x 1 nagios nagios 236304 May 28 10:33 outages.cgi
-rwxrwxr-x 1 nagios nagios 240416 May 28 10:33 showlog.cgi
-rwxrwxr-x 1 nagios nagios 314200 May 28 10:33 status.cgi
-rwxrwxr-x 1 nagios nagios 312320 May 28 10:33 statusjson.cgi
-rwxrwxr-x 1 nagios nagios 261136 May 28 10:33 statusmap.cgi
-rwxrwxr-x 1 nagios nagios 256864 May 28 10:33 statuswml.cgi
-rwxrwxr-x 1 nagios nagios 240448 May 28 10:33 statuswrl.cgi
-rwxrwxr-x 1 nagios nagios 265064 May 28 10:33 summary.cgi
-rwxrwxr-x 1 nagios nagios 252776 May 28 10:33 tac.cgi
-rwxrwxr-x 1 nagios nagios 269272 May 28 10:33 trends.cgi

I do not have an httpd command. I am not familiar with the cgi module, though looked it up for ubuntu and found this site. http://packages.ubuntu.com/lucid/libcgi-pm-perl
I did an apt-get install for libcgi-pm-perl and it did install 2 new files. I restarted Apache2 though the issue remains. Thanks for the help. :)

Re: CGI Downloading Instead of Executing

Posted: Fri May 30, 2014 8:19 am
by eloyd
Humor me, and for fun, change this line:

Code: Select all

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
to:

Code: Select all

ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/

Re: CGI Downloading Instead of Executing

Posted: Fri May 30, 2014 10:42 am
by abrist
Try:

Code: Select all

apache2 -M | grep cgi
apache -M | grep cgi

Re: CGI Downloading Instead of Executing

Posted: Mon Jun 02, 2014 9:32 am
by rbalabama
I had previously removed the quotes for the ScriptAlias and tried it again, and it did not have any impact. Reading through the config file I see the other listings did not have quotes so I am permanently removing the quotes.

I ran "apache2 -M | grep cgi" and got the following:

root@logstash141:/etc/apache2# apache2 -M | grep cgi
[Mon Jun 02 09:19:58.809490 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Mon Jun 02 09:19:58.809801 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Mon Jun 02 09:19:58.810004 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Mon Jun 02 09:19:58.810230 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Mon Jun 02 09:19:58.810493 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jun 02 09:19:58.816600 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jun 02 09:19:58.817355 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
[Mon Jun 02 09:19:58.817610 2014] [core:warn] [pid 18656] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}

looking into that error on line 74 in the config file I see where it was suggested in the file to go to the following link for more about Mutex:
http://httpd.apache.org/docs/2.4/mod/core.html#mutex
I can't say the mutex makes much sense to me so I have kept it as is at the default.

Re: CGI Downloading Instead of Executing

Posted: Mon Jun 02, 2014 11:19 am
by eloyd
Humor me, and for fun, change this line:

Code: Select all

ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
to:

Code: Select all

ScriptAlias /nagios/cgi-bin/ /usr/local/nagios/sbin/
Please note that there are slashes at the end of the directory names. It's not just about removing the quotes.

Re: CGI Downloading Instead of Executing

Posted: Mon Jun 02, 2014 4:28 pm
by tmcdonald
Let us know if eloyd's suggestion works for you

Re: CGI Downloading Instead of Executing

Posted: Tue Jun 03, 2014 6:51 am
by rbalabama
The removal of the quotes for the script alias did not have an impact. As I looked at that part of the Apache2 config file it looks like the quotes should not be included so I am permanently removing them.

Re: CGI Downloading Instead of Executing

Posted: Tue Jun 03, 2014 7:40 am
by eloyd
Please note that there are slashes at the end of the directory names. It's not just about removing the quotes. Please try my suggestion exactly as written.