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