deploying multiple dancer websites on localhost with mod_proxy
starting a new thread, for clarity sake. Is the following possible with mod_proxy (I have fudged the prompts below to illustrate my scenario)? On my laptop, with Apache ---------------------------------------- punkish ~/dance1$./dance1.pl
Dancer server xxxxx listening on http://0.0.0.0:3000/ == Entering the development dance floor ...
punkish ~/dance2$./dance2.pl
Dancer server xxxxx listening on http://0.0.0.0:3001/ == Entering the development dance floor ...
punkish ~/Documents/dance3$./dance3.pl
Dancer server xxxxx listening on http://0.0.0.0:3002/ == Entering the development dance floor ...
Then, from my browser http://localhost/dance1 http://localhost/dance2 http://localhost/dance3 -- 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 =======================================================================
replying to myself, with a resolution, and a possible new problem. On Mon, Mar 8, 2010 at 11:12 AM, P Kishor <punk.kish@gmail.com> wrote:
starting a new thread, for clarity sake. Is the following possible with mod_proxy (I have fudged the prompts below to illustrate my scenario)?
On my laptop, with Apache ---------------------------------------- punkish ~/dance1$./dance1.pl
Dancer server xxxxx listening on http://0.0.0.0:3000/ == Entering the development dance floor ...
punkish ~/dance2$./dance2.pl
Dancer server xxxxx listening on http://0.0.0.0:3001/ == Entering the development dance floor ...
punkish ~/Documents/dance3$./dance3.pl
Dancer server xxxxx listening on http://0.0.0.0:3002/ == Entering the development dance floor ...
Then, from my browser
http://localhost/dance1 http://localhost/dance2 http://localhost/dance3
There is something weird with Apache. Seems like under certain conditions, or for certain settings, Apache doesn't recognize changes in conf with just a simple 'apachctl graceful'. After struggling with this for a day and a half, I remembered something similar happening a few months ago with mod_rewrite. The solution was to reboot the machine. I know this sounds stupid, and has no basis in scientific logic, but I rebooted the laptop, and bingo! mod_proxy started working. I do hope this helps someone else. Now, a new problem... so, I have the following on my hard disk ~/dance/punkishdance %./punkishdance.pl
Dancer server 2139 listening on http://0.0.0.0:3000 == Entering the development dance floor ...
And, I have the following in my httpd.conf file ProxyRequests Off <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass /punkishdance/ http://localhost:3000/ ProxyPassReverse /punkishdance/ http://localhost:3000/ 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? 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} }; }; get '/' => sub { template 'page', { page => _page('Intro-Page'), name => params->{p} }; }; Why is it not possible to combine the above two into a single route with an optional param kinda like so get '/:p?' => sub { params->{p} eq 'Intro-Page' unless params->{p}; template 'page', { page => _page(params->{p}), name => params->{p} }; }; -- 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 =======================================================================
On Mon, Mar 8, 2010 at 5:04 PM, P Kishor <punk.kish@gmail.com> wrote:
replying to myself, with a resolution, and a possible new problem.
On Mon, Mar 8, 2010 at 11:12 AM, P Kishor <punk.kish@gmail.com> wrote:
starting a new thread, for clarity sake. Is the following possible with mod_proxy (I have fudged the prompts below to illustrate my scenario)?
On my laptop, with Apache ---------------------------------------- punkish ~/dance1$./dance1.pl
Dancer server xxxxx listening on http://0.0.0.0:3000/ == Entering the development dance floor ...
punkish ~/dance2$./dance2.pl
Dancer server xxxxx listening on http://0.0.0.0:3001/ == Entering the development dance floor ...
punkish ~/Documents/dance3$./dance3.pl
Dancer server xxxxx listening on http://0.0.0.0:3002/ == Entering the development dance floor ...
Then, from my browser
http://localhost/dance1 http://localhost/dance2 http://localhost/dance3
There is something weird with Apache. Seems like under certain conditions, or for certain settings, Apache doesn't recognize changes in conf with just a simple 'apachctl graceful'. After struggling with this for a day and a half, I remembered something similar happening a few months ago with mod_rewrite. The solution was to reboot the machine. I know this sounds stupid, and has no basis in scientific logic, but I rebooted the laptop, and bingo! mod_proxy started working.
I do hope this helps someone else.
Now, a new problem... so, I have the following on my hard disk
~/dance/punkishdance %./punkishdance.pl
Dancer server 2139 listening on http://0.0.0.0:3000 == Entering the development dance floor ...
And, I have the following in my httpd.conf file
ProxyRequests Off
<Proxy *> Order deny,allow Allow from all </Proxy>
ProxyPass /punkishdance/ http://localhost:3000/ ProxyPassReverse /punkishdance/ http://localhost:3000/
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?
In fact, the browser is unable to get any file directly from under ~/dance/punkishdance the stylesheets, the images, nothing comes through. In my dancer routes, I need the equivalent of RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d
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} }; };
get '/' => sub { template 'page', { page => _page('Intro-Page'), name => params->{p} }; };
Why is it not possible to combine the above two into a single route with an optional param kinda like so
get '/:p?' => sub { params->{p} eq 'Intro-Page' unless params->{p}; template 'page', { page => _page(params->{p}), name => params->{p} }; };
-- 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 =======================================================================
On Monday 08 March 2010 23:21:00 P Kishor wrote:
On Mon, Mar 8, 2010 at 5:04 PM, P Kishor <punk.kish@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).
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, 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. -- David Precious <davidp@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)
On Mon, Mar 8, 2010 at 5:58 PM, David Precious <davidp@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@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@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@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 =======================================================================
On Mon, Mar 8, 2010 at 5:58 PM, David Precious <davidp@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@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).
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, 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.
ok, I found and read up on the auto_page setting. That doesn't seem to be what I want. I want stuff in $appdir/public to be served directly, and that is not happening right now. -- Puneet Kishor
Le lundi 08 mars 2010 à 18:26 -0600, P Kishor a écrit :
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.
ok, I found and read up on the auto_page setting. That doesn't seem to be what I want. I want stuff in $appdir/public to be served directly, and that is not happening right now.
Please, don't mixup things. You have two issues: 1. You want a smart route handler that can match any path requested and serve the appropriate content (retreived from a database), depending on the path. You can't do that with a token-pattern match. If you want to write a "catchall" route handler, you have to use a regexp-pattern like the following: get r('/(.*)') => sub { my $path = request->path; # ... do what you want with $path }; 2. Your static files are not served This is not a Dancer issue, this is a configuration issue. First of all, monitor your Apache access/error logs when you hit your app, and look for the reason of the 404. Maybe Apache doesn't pass the baton to Dancer when it's a static file that is requested, and maybe your DocumentRoot points to a bad location... It can come from many, many reasons, and it's quite impossible for us, on the mailing list, to debug your apache installation. But please, when you write a mail with a request for help on that mailing list, try to focus on one problem at a time, mixing up different issues in the same mail is hard to follow... and to help ;) Happy dancing. -- Alexis Sukrieh
participants (3)
-
Alexis Sukrieh -
David Precious -
P Kishor