mod_cgi for nginx - anyone?

Igor Sysoev is at
Sat Feb 7 13:16:55 MSK 2009

On Fri, Feb 06, 2009 at 02:55:25PM -0800, mike wrote:

> Igor, et al:
> Is there a reason that there has not been an attempt to directly call
> CGI programs (compiled CGI, perl CGI, whatever) in nginx?
> I would love to take out proxying to apache if I could.
> Is there a blocking nature in CGI or something else that makes it
> impossible to function, or has there been no interest? I have a
> handful of apps I have to support (bugzilla, mailman, etc.) that I
> have to proxy to apache right now.
> I'd be willing to put some money down for it, too. (and mod_svn !)

nginx is not general purpose server, it's rather highload server.
CGI is not compatible with highload: if you run Apache/CGI, then CGI
will became bottleneck much earlier than Apache.

There are two ways to implement CGI inside nginx:

1) simple one: just fork()ing worker process that has received a request
for CGI and exec() a CGI program. It's simple enough, but has a lot
of overhead. Besides CGI programs will run with worker privilege only.

2) complex way: to run a special CGI manager (probably with root privilege
as master process) and to pass it requests/sockets using Unix domain sockets.
Then the manager can fork/exec CGI programs with required privileges
and with minimal overhead to nginx workers.

The second way will require some time to program, but the outcome will
be much similar like just proxying to mini_httpd
( ).

BTW, it seems that using Apache with several worker processes (2-5) for
bugzilla, mailman, etc. will not consume much CPU/memory: look top.

Igor Sysoev

More information about the nginx mailing list