How to process only first path element in the URL as the CGI executable

António P. P. Almeida appa at
Sat Oct 9 07:19:01 MSD 2010

On 8 Out 2010 16h02 WEST, vfclists at wrote:

> [1 <multipart/alternative (7bit)>] [1.1 <text/plain; ISO-8859-1
> (7bit)>] I am using a FreePascal web module designed for apache
> cgi-bin with nginx.
> The CGI itself is called spidersample.cgi and contains modules such
> as hello, bye etc.
> With Apache when spidersample.cgi/hello is called, spidersample.cgi
> gets executed, and passes control to the hello subroutine it
> contains.

Isn't there something missing here? I would expect for a query string
separator somewhere that signals the application data portion of the
URI. It should be a '?', according to

Something like spidersample.cgi?q=hello or similar.

I'm guessing that there's some rewrite rule in the Apache config that
didn't get converted to nginx. Hence the script is failing. And it
makes sense according to the config. After all any request not ending
in .cgi is handled "as usual" by nginx, therefore it tries to get the
file in /home/rchurch/Data/Lazarus/CgiApps/spidersample.cgi/hello. If
it doesn't exist it returns a 404.

> With nginx instead of executing spidersample.cgi it treats
> spidersample.cgi/hello as meaning a hello file in a spidersample.cgi
> directory, and returns with a 404 error as there is no such
> directory.


> I suspect it is an easily fixed problem with some rewrite rules in
> the configuration file and it is posted below.

The rewrite rule must be in the Apache config, find it and port it to nginx.

--- appa

More information about the nginx mailing list