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

Frank Church vfclists at gmail.com
Sat Oct 9 00:10:27 MSD 2010


On 8 October 2010 16:55, Francis Daly <francis at daoine.org> wrote:

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

I removed the "$" and now this is the error message I get:

2010/10/08 21:06:46 [error] 14628#0: *22 FastCGI sent in stderr: "Cannot
chdir to script directory
(/home/rchurch/Data/Lazarus/CgiApps/spidersample.cgi)" while reading
response header from upstream, client: 127.0.0.1, server: localhost,
request: "GET /spidersample.cgi/hello HTTP/1.1", upstream:
"fastcgi://unix:/tmp/rchurch_cgi.sock:", host: "localhost:8118", referrer: "
http://localhost:8118/spidersample.cgi"




> 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
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



-- 
Frank Church

=======================
http://devblog.brahmancreations.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nginx.org/pipermail/nginx/attachments/20101008/54e7d5e1/attachment.html>


More information about the nginx mailing list