duplicating apps with different setup

11 views
Skip to first unread message

harold

unread,
Aug 24, 2012, 6:47:29 AM8/24/12
to psgi-...@googlegroups.com
Hi

I'm trying to work out if it is even possible to do the following and, if so, how.

I want to run two virtual servers (on the same machine) using a single catalyst app but with two different configs.

I have been able to achieve the result I want for each server by changing the location of static files using Plack's Static middleware; but not both at the same time. And I can run two servers by applying Static outside the mounts, but then both share the same static path.

This, simplified, is what I tried.

...
use MyApp;
MyApp->apply_default_middlewares(MyApp->psgi_app);;

$myapp1 = MyApp->psgi_app(@_);
$myapp2 = MyApp->psgi_app(@_);
my $home1 = '/path/to/static1';
my $home2 = '/path/to/static2';

builder {
  mount "/server1"      => builder {
    enable "Static", path => qr!^/(js|css)|docs!, root => "$home1/root/";
 enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' }
      "Plack::Middleware::ReverseProxy";
    $myapp1;
  };
  mount "/server2"      => builder {
    enable "Static", path => qr!^/(js|css)|docs!, root => "$home2/root/";
 enable_if { $_[0]->{REMOTE_ADDR} eq '127.0.0.1' }
      "Plack::Middleware::ReverseProxy";
    $myapp2;
  };

};


But when I do this, neither server can find any static files.

Eventually I'd want to add this to an nginx setup, I think. Should I be looking there instead?

Thanks

Harold

Tatsuhiko Miyagawa

unread,
Aug 24, 2012, 1:27:10 PM8/24/12
to psgi-...@googlegroups.com
On Fri, Aug 24, 2012 at 3:47 AM, harold <harold....@guardian.co.uk> wrote:

> But when I do this, neither server can find any static files.

What is your actual URL pattern and what log do you get?

> Eventually I'd want to add this to an nginx setup, I think. Should I be
> looking there instead?
>
> Thanks
>
> Harold
>
> --
>
>
>



--
Tatsuhiko Miyagawa
Reply all
Reply to author
Forward
0 new messages