How do webserver and cgi process communicate with each other? How do webserver and cgi process communicate with each other? nginx nginx

How do webserver and cgi process communicate with each other?


A CGI application is simply a standard executable or script - each HTTP request to the web server corresponds to a single execution / instance of that executable or script where environment variables are used to pass information about the request (such as the request URL and request method) and the HTTP request body is passed on the standard input. The script / executable the passes the raw HTTP output through the standard output stream to the web server.

For a example of a CGI application see the wikipedia page for an example perl script and for more detail have a read through of the CGI specification


Fast CGI is an attempt to reduce the overhead of the CGI interface - as starting a new process is a relatively expensive task on many operating systems, Fast CGI attempts to reduce this by allowing a single long-running Fast CGI process to handle many HTTP requests.

Although many parts of Fast CGI are similar to CGI (for example the format of the environment variables), with Fast CGI all information is passed through the standard input stream.

You should try looking at the Fast CGI website for more information - in particular the Fast CGI specification is on there and explains all of this in detail.