Skip to content

How do i map ports to applications?

ranguard edited this page Jan 28, 2011 · 4 revisions

You can run apps separately using:

starman --listen :8080 /psgi/app1.psgi 
starman --listen :9090 /psgi/app2.psgi

You can then use Perlbal's VHOST plugin to proxy to the correct port depending on the domain name.

If you wish to run only one starman, but for several applications

starman --listen :8080 --listen :9090 /psgi/app.psgi

app.psgi:

my %port2app = (5000 => $app1, 5001 => $app2);
sub { 
   my $env = shift; 
   $port2app{ $env->{SERVER_PORT} }->($env)
};

This only works in servers which correctly support the SERVER_PORT env

Supported servers:

  • Starman
  • Twiggy (version 0.1011 or greater)