[Dancer-users] deploying multiple dancer websites on localhost with mod_proxy

P Kishor punk.kish at gmail.com
Tue Mar 9 01:07:44 CET 2010


On Mon, Mar 8, 2010 at 5:58 PM, David Precious <davidp at preshweb.co.uk> wrote:
> On Monday 08 March 2010 23:21:00 P Kishor wrote:
>> On Mon, Mar 8, 2010 at 5:04 PM, P Kishor <punk.kish at gmail.com> wrote:
>> > Now, when I point my browser at http://localhost/punkishdance, I get
>> > my website, except...
>> >
>> > the browser can't retrieve stuff under ~/dance/punkishdance/public,
>> > for example, the browser throws a 404 for
>> > http://localhost/punkishdance/public/css/grid.css which is at
>> > ~/dance/punkishdance/css/style.css
>> >
>> > I can't get it directly, and of course, I can't get it included in web
>> > page, via main.tt. How do I correct this?
>
> Is the file really in $appdir/css/style.css, or did you mean
> $appdir/public/css/style.css?  (It should be the latter).
>

I meant the latter... yes, the missing file is $appdir/public/css/style.css


>
>> In fact, the browser is unable to get any file directly from under
>> ~/dance/punkishdance
>
> Indeed, the only files which should be automatically served are those in
> $appdir/public (for instance, ~/dance/punkishdance/public/).
>

And, the above is exactly what I am not getting.

> (And, if you're using the new auto_page feature, Dancer will look for a
> matching template in the views dir if no route matched.
>
> Which leads me nicely on to...
>
>> > Which brings me to an associated question. I have the following routes in
>> > my app
>> >
>> > get '/:p' => sub {
>> >    pass unless (defined params->{p});
>> >    template 'page', { page => _page(params->{p}), name => params->{p} };
>> > };
>
> You should find the auto_page feature ideal for that... with that enabled,
> creating $appdir/views/mypage.tt means the a request for /mypage will
> automatically be handled using that view, without you needing to declare any
> route to match it.
>

What is the auto_page feature, and how do I use it? In any case, I
have my pages in a database, so my logic is, if a page is explicitly
requested as a param in path_info, retrieve that from the db and serve
it up. If no page is defined, then serve a default page.

I have also now discovered that ProxyPass doesn't handle trailing slashes.

    ProxyPass /punkishdance/ http://localhost:3000/
    ProxyPassReverse /punkishdance/ http://localhost:3000/

lets me get to http://localhost/punkishdance/ but not to
http://localhost/punkishdance

I can define two separate rules,

    ProxyPass /punkishdance http://localhost:3000/
    ProxyPassReverse /punkishdance http://localhost:3000/

and that seems to work, but Apache warns me with the following error

[Mon Mar 08 17:34:50 2010] [warn] worker http://localhost:3000/
already used by another worker


Seems like the only way around this is to also involve mod_rewrite with

    RewriteRule ^/punkishdance$ punkishdance/ [R]

and, I was hoping to avoid mod_rewrite completely.


> --
> David Precious <davidp at preshweb.co.uk>
> http://blog.preshweb.co.uk/    www.preshweb.co.uk/twitter
> www.preshweb.co.uk/linkedin    www.preshweb.co.uk/facebook
> www.preshweb.co.uk/identica    www.lyricsbadger.co.uk
>
>  "Programming is like sex. One mistake and you have to support
>  it for the rest of your life". (Michael Sinz)
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
>



-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list