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

Frank Church vfclists at gmail.com
Sat Oct 9 23:31:27 MSD 2010


I tried your suggestion and it worked.

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

Thanks

On 9 October 2010 11:12, Francis Daly <francis at daoine.org> wrote:

> On Fri, Oct 08, 2010 at 09:10:27PM +0100, Frank Church wrote:
> > 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 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.
>
> > > >         location ~ \.cgi$ {
>
> > > Your request for "/spidersample.cgi/hello" doesn't match, and so
> doesn't
> > > use this config.
>
> > 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"
>
> That suggests that this location block is now being used
> for this request, which is good. The error is because the
> fastcgi processor was told that the SCRIPT_FILENAME was
> /home/rchurch/Data/Lazarus/CgiApps/spidersample.cgi/hello,
> which is untrue. SCRIPT_FILENAME is
> "/home/rchurch/Data/Lazarus/CgiApps/spidersample.cgi".
>
> Also, the script itself almost certainly uses PATH_INFO to determine
> which module of its own to use -- "hello", "echo", or some other --
> so you'll want to set that too.
>
> The easiest way to do both is probably to use fastcgi_split_path_info. See
> the two new lines below that include the string "path_info".
>
> Note -- it is possible that all of the fastcgi_param lines are unnecessary
> if they are already in the included /etc/nginx/fastcgi_params. You can
> experiment with removing them at leisure.
>
>
>    location ~ \.cgi {
>            fastcgi_split_path_info (.*\.cgi)(/.*);
>             include /etc/nginx/fastcgi_params;
>            fastcgi_pass unix:/tmp/sysman_cgi.sock;
>             fastcgi_param  SCRIPT_FILENAME
> $document_root$fastcgi_script_name;
>             fastcgi_param  QUERY_STRING     $query_string;
>            fastcgi_param  REQUEST_METHOD   $request_method;
>            fastcgi_param  CONTENT_TYPE     $content_type;
>            fastcgi_param  CONTENT_LENGTH   $content_length;
>             fastcgi_param  PATH_INFO        $fastcgi_path_info;
>     }
>
>
> > > Then you can change the location definition to include all and only the
> > > requests you want handled this way.
>
> That bit should still be done.
>
> All the best,
>
>        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/20101009/cbd23d2b/attachment-0001.html>


More information about the nginx mailing list