CGI Downloading Instead of Executing

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
rbalabama
Posts: 8
Joined: Thu May 29, 2014 12:16 pm

CGI Downloading Instead of Executing

Post 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>
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: CGI Downloading Instead of Executing

Post 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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
rbalabama
Posts: 8
Joined: Thu May 29, 2014 12:16 pm

Re: CGI Downloading Instead of Executing

Post 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. :)
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: CGI Downloading Instead of Executing

Post 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/
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: CGI Downloading Instead of Executing

Post by abrist »

Try:

Code: Select all

apache2 -M | grep cgi
apache -M | grep cgi
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
rbalabama
Posts: 8
Joined: Thu May 29, 2014 12:16 pm

Re: CGI Downloading Instead of Executing

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: CGI Downloading Instead of Executing

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: CGI Downloading Instead of Executing

Post by tmcdonald »

Let us know if eloyd's suggestion works for you
Former Nagios employee
rbalabama
Posts: 8
Joined: Thu May 29, 2014 12:16 pm

Re: CGI Downloading Instead of Executing

Post 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.
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: CGI Downloading Instead of Executing

Post 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.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Locked