[Dancer-users] Serving DirectoryIndex via Dancer fails

David Precious davidp at preshweb.co.uk
Thu Mar 17 16:03:19 CET 2011


On Thu, 2011-03-17 at 09:47 -0500, Mr. Puneet Kishor wrote:
> 
> 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 --

You've got it the wrong way round; Apache needs to determine whether to
serve up a file itself, or pass the request off to your Dancer app.
There's no way for Dancer, once it's been given a request, to identify
that it should not be serving it and tell Apache to do it itself.

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

What is your DocumentRoot set to?

You'll want to configure the DocumentRoot to point to your public
folder; given that, Apache *should* serve up files  which exist in that
directory directly, rather than passing them to Dancer.


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

Dancer doesn't get a choice in it; if the request has reached Dancer,
that's your web server's configuration; Dancer has no way to say to
Apache "No, I don't handle that, you do".

Hope that helps a little?

Cheers

Dave P

-- 
David Precious  ("bigpresh")
http://www.preshweb.co.uk/

   "Programming is like sex. One mistake and you have to support
   it for the rest of your life". (Michael Sinz)




More information about the Dancer-users mailing list