# Nginx perl cgi

**URL:** <https://www.ruby-forum.com/t/nginx-perl-cgi/131807>\
**Category:** NGINX\
**Created:** [March 13, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807 "2008-03-13T13:24:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [March 13, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/1 "2008-03-13T13:24:07Z")

</div>

Hello,

I have some problems running (perl) cgi scripts with nginx.  
I followed the config at [http://wiki.codemongers.com/NginxSimpleCGI](http://wiki.codemongers.com/NginxSimpleCGI)  
Perl scripts work very well as long as they use method=get in forms. If  
they use method=post, it seems no input is passed to the cgi.

I saw in perl-fcgi.pl that there was some lines: "if  
(($req\_params{‘REQUEST\_METHOD’} eq ‘POST’) && ($req\_len != 0) ){ "  
Which should pass the info

Has someone an idea of what’s happening?

Regards

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [March 13, 2008, 6:37pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/2 "2008-03-13T18:37:05Z")

</div>

I had the same problem some time ago.  
The problem with this script is that it violates CGI specifications  
regarding  
POST requests. POSTed data must come to a CGI app from the standard  
input  
while this script parses the input and sets variables as if they came  
via a  
GET request, passing nothing to app’s stdin. Thus, applications that  
follow  
specs strictly and expect POST data from stdin, fail.

I’ve modified the script to fix the problem, feel free to use it.

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [March 13, 2008, 8:34pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/3 "2008-03-13T20:34:57Z")

</div>

Denis S. Filimonov wrote:

> I had the same problem some time ago.  
> The problem with this script is that it violates CGI specifications regarding  
> POST requests. POSTed data must come to a CGI app from the standard input  
> while this script parses the input and sets variables as if they came via a  
> GET request, passing nothing to app’s stdin. Thus, applications that follow  
> specs strictly and expect POST data from stdin, fail.
> 
> I’ve modified the script to fix the problem, feel free to use it.

Thanks, it works like a charm.

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [March 26, 2009, 9:05pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/4 "2009-03-26T21:05:27Z")

</div>

Nz2007 Nz2007 wrote:

> I too followed the same tutorial, however, when i try to run the script:
> 
> # perl /usr/bin/cgiwrap-fcgi.pl&
> 
> [1] 17845
> 
> # bind/listen: No such file or directory
> 
> (I added & at the end because i use Bash).
> 
> Hints are much welcome.
> 
> Nuno.

Look like a dir /var/run/nginx not created

they need by created and you need permission for write into it

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [May 24, 2008, 8:27pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/5 "2008-05-24T20:27:05Z")

</div>

Renaud Allard wrote:

> Denis S. Filimonov wrote:
> 
> > I had the same problem some time ago.  
> > The problem with this script is that it violates CGI specifications regarding  
> > POST requests. POSTed data must come to a CGI app from the standard input  
> > while this script parses the input and sets variables as if they came via a  
> > GET request, passing nothing to app’s stdin. Thus, applications that follow  
> > specs strictly and expect POST data from stdin, fail.
> > 
> > I’ve modified the script to fix the problem, feel free to use it.
> 
> Thanks, it works like a charm.

I too followed the same tutorial, however, when i try to run the script:

# perl /usr/bin/cgiwrap-fcgi.pl&

[1] 17845

# bind/listen: No such file or directory

(I added & at the end because i use Bash).

Hints are much welcome.

Nuno.

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [July 13, 2014, 10:13pm UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/6 "2014-07-13T22:13:54Z")

</div>

Denis S. Filimonov wrote in post #645832:

> I had the same problem some time ago.  
> The problem with this script is that it violates CGI specifications  
> regarding  
> POST requests. POSTed data must come to a CGI app from the standard  
> input  
> while this script parses the input and sets variables as if they came  
> via a  
> GET request, passing nothing to app’s stdin. Thus, applications that  
> follow  
> specs strictly and expect POST data from stdin, fail.
> 
> I’ve modified the script to fix the problem, feel free to use it.

Hi Denis,

Do you have an alternative solution for Windows?  
Syscall and setsid is not working in Windows environments.

Regards,  
Peter

---

<div class="post-metadata">

**Author:** ![Renaud\_Allard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/9fc348/32.png) [@Renaud\_Allard](https://www.ruby-forum.com/u/Renaud_Allard)\
**Post date:** [August 8, 2010, 3:41am UTC](https://www.ruby-forum.com/t/nginx-perl-cgi/131807/7 "2010-08-08T03:41:43Z")

</div>

I’d like a solution with using spawn-fcgi.

As I understand it, that Perl wrapper forks into background itself.

I have a script where I load all FastCGI wrappers from:

spawn-fcgi -C 3 -u www-data -s /var/run/php-fcgi.sock -P  
/var/run/php-fcgi.pid – /usr/bin/php5-cgi  
spawn-fcgi -F 3 -u www-data -s /var/run/lua-fcgi.sock -P  
/var/run/lua-fcgi.pid – /usr/bin/wsapi.fcgi

it works very well that way, and I have PID files, that I can use to  
kill the wrappers with:

kill $(cat /var/run/php-fcgi.pid)  
kill $(cat /var/run/lua-fcgi.pid)

I’d like a Perl wrapper that works in the same way, meaning that I’d  
pass most stuff with spawn-fcgi. Also, It would give me the possibility  
of controlling how many children I want to spawn (-F switch).

Is there a solution that uses spawn-fcgi? I was looking for something  
like that, But there’s only little, and most of it is quite confusing.

Regards,  
–polemon
