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

Francis Daly francis at daoine.org
Tue Oct 12 01:29:02 MSD 2010


On Sat, Oct 09, 2010 at 08:31:27PM +0100, Frank Church wrote:

Hi there,

> I tried your suggestion and it worked.

Good stuff.

> I have yet to learn more about "changing the location definition to include
> all and only the
>   requests you want handled this way."

It's the usual security/convenience trade-off. If you know that you're
the only person who can add accessible urls to the server, then you
can make sure that nothing with ".cgi" in the name that might lead to
a security breach will be added.

I prefer to have a less generic configuration -- so, for example, only
files in the /cgi-bin/ namespace should be processed by the fastcgi
server; or perhaps even only spidersample.cgi should be processed
that way.

You have to decide what urls should go to the fastcgi service, and find
one or more location patterns that match all of those urls, and match no
other urls.

So maybe something like

   location ~ spidersample.cgi

or

   location ~^ /spidersample.cgi

or

   location ~ /cgi-bin/*\.cgi

or even

   location ~ /spidersample.cgi($|/)

will suit your requirements.

All the best,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list