documentation:2.1:configplack

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

documentation:2.1:configplack [2019/01/15 15:55] (current)
Line 1: Line 1:
 +====== Deploy LemonLDAP::NG on a Plack server ======
  
 +[[https://metacpan.org/release/Plack|Plack]] is a powerful engine that powers many very fast [[http://plackperl.org/#servers|servers]]. LLNG uses some Plack libraries to run as FastCGI server. So, It can be easily run on these servers. See also [[psgi|Advanced PSGI usage]] if you want to replace LLNG FastCGI server.
 +
 +===== Complete example =====
 +
 +<file perl llapp.psgi>
 +#!/usr/bin/perl
 +
 +use Data::Dumper;
 +use Plack::Builder;
 +
 +# Basic test app
 +my $testApp = sub {
 +    my ($env) = @_;
 +    return [
 +        200,
 +        [ 'Content-Type' => 'text/plain' ],
 +        [ "Hello LLNG world\n\n" . Dumper($env) ],
 +    ];
 +};
 +
 +# Build protected app
 +my $test = builder {
 +    enable "Auth::LemonldapNG";
 +    $testApp;
 +};
 +
 +# Build portal app
 +use Lemonldap::NG::Portal::Main;
 +my $portal = builder {
 +    enable "Plack::Middleware::Static",
 +      path => '^/static/',
 +      root => '/path/to/portal/htdocs/';
 +    Lemonldap::NG::Portal::Main->run( {} );
 +};
 +
 +# Build manager app
 +use Lemonldap::NG::Manager;
 +my $manager = builder {
 +    enable "Plack::Middleware::Static",
 +      path => '^/static/',
 +      root => '/path/to/manager/htdocs/';
 +    enable "Plack::Middleware::Static",
 +      path => '^/doc/',
 +      root => '/path/to/dir/that/contains/"doc"';
 +    enable "Plack::Middleware::Static",
 +      path => '^/lib/',
 +      root => '/path/to/doc/pages/documentation/current/';
 +    Lemonldap::NG::Manager->run( {} );
 +};
 +
 +# Global app
 +builder {
 +    mount 'http://test1.example.com/'   => $test;
 +    mount 'http://auth.example.com/'    => $portal;
 +    mount 'http://manager.example.com/' => $manager;
 +};
 +
 +</file>
 +
 +Launch it with [[https://github.com/miyagawa/Starman|Starman]] for example:
 +<code:bash>
 +$ starman --port 80 --workers 32 llapp.psgi
 +</code>