Unable to curl against cmd.cgi

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.
Locked
zeotech
Posts: 4
Joined: Thu Nov 19, 2020 3:19 am

Unable to curl against cmd.cgi

Post by zeotech »

I am running this command

Code: Select all

curl -s -S http://nagios.example.com/nagios/cgi-bin/cmd.cgi -u nagiosadmin:nagios -d "cmd_typ=22&host=localhost&service=SSH"
when I run the command I get;

Code: Select all

<html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.17.8</center>
</body>
</html>
[Environmental Information]
OS: CentOS Linux release 8.2.2004 (Core)
WebServer: nginx version: nginx/1.17.8
Nagios: Ver 4.4.6

Is there any solution?
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Unable to curl against cmd.cgi

Post by gormank »

Have you tried simplifying things and just using curl on http://nagios.example.com? http://nagios.example.com/nagios?
zeotech
Posts: 4
Joined: Thu Nov 19, 2020 3:19 am

Re: Unable to curl against cmd.cgi

Post by zeotech »

I've solved it myself.
Modified nginx.conf as follows

Code: Select all

        location ~ \.cgi$ {
           fastcgi_pass 127.0.0.1:9001;
           fastcgi_split_path_info           ^/nagios/cgi-bin/(.+\.cgi)(.*)$;
           fastcgi_param CONTENT_LENGTH     $content_length;    ←This added.
           fastcgi_param QUERY_STRING       $query_string;
           fastcgi_param REQUEST_METHOD     $request_method;
           fastcgi_param SCRIPT_FILENAME    /var/home/lib/nagios446/sbin/$fastcgi_script_name;
           fastcgi_param REMOTE_USER        $remote_user;
           fastcgi_param AUTH_USER          $remote_user;
           auth_basic "Nagios Access";
           auth_basic_user_file /var/home/lib/nagios446/etc/htpasswd.users;
         }
Is this correct?
Locked