perlplackpsgi

How to setup Apache-like name-based virtual hosts with Starman


In my previous question I asked about a multi-domain solution, but the question was too complex.

Now in short:

Is it possible to somehow setup name-based virtual hosts with Starman (or with any other pure perl PSGI server) like with Apache's <VirtualHost ...> directive? Or do I need to use Apache to get this kind of functionality?

Any idea?


Solution

  • The middleware is already done in Plack::Builder with Plack::App::URLMap. The pod saying:

    Mapping URL with host names is also possible, and in that case the URL mapping works like a virtual host.

    Syntax is in 3rd mount:

     builder {
          mount "/foo" => builder {
              enable "Plack::Middleware::Foo";
              $app;
          };
    
          mount "/bar" => $app2;
          mount "http://example.com/" => builder { $app3 };
      };