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

Francis Daly francis at daoine.org
Fri Oct 8 19:55:50 MSD 2010


On Fri, Oct 08, 2010 at 04:02:48PM +0100, Frank Church wrote:

Hi there,

> With Apache when spidersample.cgi/hello is called, spidersample.cgi gets
> executed, and passes control to the hello subroutine it contains.

That'll be due to the way Apache is configured.

> With nginx instead of executing spidersample.cgi

nginx doesn't execute cgi programs. It usually is configured either to
proxy_pass the request to a http server that will, or to fastcgi_pass
with params to a fastcgi-processing server.

It might just be a terminology difference, or it might be important to
your image of what happens.

> 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.

That's probably down to the (default) configuration.

>         location ~ \.cgi$ {

That says "for any request that ends in the four characters '.cgi',
use this config".

Your request for "/spidersample.cgi/hello" doesn't match, and so doesn't
use this config.

For initial testing, if you remove the "$", then the config will be
used for any request that includes the 4-char string ".cgi". That should
allow you to confirm the rest of the configuration.

Then you can change the location definition to include all and only the
requests you want handled this way.

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list