[Dancer-users] Serving DirectoryIndex via Dancer fails

Mr. Puneet Kishor punk.kish at gmail.com
Thu Mar 17 15:47:05 CET 2011


On Mar 17, 2011, at 9:31 AM, David Precious wrote:

> On Thu, 2011-03-17 at 08:49 -0500, Mr. Puneet Kishor wrote:
>> My httpd.conf is set to serve DirectoryIndex index.html and index.cgi. 
> 
> httpd.conf is irrelevant to Dancer's behaviour.
> 
>> Yet, if I go to [http://punkish.org/geoweb] or [http://punkish.org/opengov], Dancer 
>> thinks I am trying to query for a page called geoweb or opengov -- I was under the 
>> impression that it would first see if by adding a trailing slash to the requested 
>> URI, it could located static directory.
> 
> It'll simply look for a matching file and serve it if found.  Dancer's
> static file serving is designed simply to serve up static files
> (images/CSS/Javascript etc) for a dynamic Dancer-powered web-app, not
> really to be a webserver to replace Apache/Nginx etc.  In fact, for a
> busier site, I'd recommend configuring e.g. Nginx in front of the Dancer
> app to serve up the static files itself, and only pass through the
> requests which actually need to be handled by the Dancer app.
> 
> I don't personally think that Dancer's static file serving should be
> extended to support DirectoryIndex etc; when you start to need that sort
> of thing, you should probably let a proper web server do it.
> 
> Why not just configure Apache to serve those specific static sites
> itself, rather than involving Dancer in it?

What you explain above makes sense, but not completely (to me). I thought I was doing just that -- having Dancer serve dynamic portion of my site, and letting Apache do its work for the static parts. All Dancer had to do was to determine whether a static file or directory was being requested; if yes, then let Apache do its job. In fact, if I understand correctly, the sequence is like so --

My .htaccess is

RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule (.*) /dispatch.cgi/$1 [L]

Apache receives a request for http://punkish.org(.*)

if (.*) is not a directory or a filename, Apache hands the job to Dancer via dispatch.cgi

So, if I understand correctly, Dancer shouldn't even have gotten involved when http://punkish.org/geoweb was requested, because Apache would have determined that I was requesting a directory. In other words, I am not asking for Dancer to be extended to replace Apache/Nginx, but to not get involved when a directory or a file are requested by name.

With regards to Nginx, I am studying how to move to it, but there are many issues with it that are not clear to me. Baby steps for now.

Many thanks,

Puneet.



More information about the Dancer-users mailing list