[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGI Mapping



Nathan R Heagy schrieb:
> 
> I have been using pi3 for quite a while and have really, really enjoyed it.
> Of all the servers I have used, it is my favorite. However, I use it for
> testing CGI applications before I upload them to my Apache-running web
> server. Unfortunately, my current, large, application needs to be able to
> run PERL scripts and HTML in the same directory, like Apache can, so I am
> forced to search for a new solution, which means a new web server. Holger,
> John? Is there any way to have both CGI and HTML served up in one directory?
> Frankly, whatever the mapping, both need to know extensions to do anything
> right, so I don't know why I can't just have .cgi be scripts, but I can't.
> 
> Thanks for any help.
> Nathan R Heagy
> -- -- --
> Sites Built Better
> http://heagy.com
^^^^^ Hi,

Here's the solution (one variant):

You've only to change Config.Pi3 in the following way:

1.) Default handler
Search for
	Handle Condition="&and(&not(&dblookup(response,string,ObjectMap)),\
&not(&regexp('internal/*',$c)))" SendFile

Insert the following line before it
	Handle CGIScripts

2.) Insert a new handler object named 'CGIScripts'

<Object>
	Name CGIScripts
	Class FlexibleHandlerClass
	Condition Condition="&regexp('text/x-perl',$c)"
	CheckPath RefuseFileByMask AllowFileMask="EFD" RefuseStatus=404
	CheckPath RefuseFileByMask AllowFileMask="F" RefuseStatus=403
	CheckPath ReturnCode ReturnCode=COMPLETED
	CheckAccess AccessByFile RequirePermissions="X"
	CheckType ReturnCode ReturnCode=COMPLETED
	Handle StandardCGI
</Object>

Explanation:
The 'CGIScripts' handler is exactly the same as the 'Scripts'
handler for Standard CGI except of the condition. It works with requests
redirected to the path mapper when the mime type is 'text/x-perl'.
With this configuration every .pl or .cgi file is executed when it is
handled by the default handler (With other words - if the request was
dispatched to the PathMapper).

Discussion:
For a production server there's to be done some more distinction - 
where is a download area and where an area for execution?
It is possible to extend the handler for other mime types too.
You can also change it in a way that the condition is the file extension
from the requested resource since some mime-types are for multiple extensions
and not all of them are executables (i.e. .exe and application/octet-stream).

Hope this helps, it works good on my system.
-- 
with regards
Holger

---------------------------------------------------------
Holger 'Zimpel' Zimmermann    Contact me:
---------------------------------------------------------
Wendishain                    tel./fax company: on demand
Germany                       tel./fax private: on demand
---------------------------------------------------------
homepage: http://home.t-online.de/home/zimpel/
web server: surf to it from my homepage (online every
            Sunday 20:00-24:00 GMT, start shifted again)
e-Mail:     zimpel@t-online.de
--------------------------------------------------------