Page 1 of 1

Unable to curl against cmd.cgi

Posted: Thu Nov 19, 2020 3:28 am
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?

Re: Unable to curl against cmd.cgi

Posted: Thu Nov 19, 2020 4:32 pm
by gormank
Have you tried simplifying things and just using curl on http://nagios.example.com? http://nagios.example.com/nagios?

Re: Unable to curl against cmd.cgi

Posted: Thu Nov 19, 2020 8:05 pm
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?