| 1 |
Deploy LemonLDAP::NG on a Plack server |
| 2 |
====================================== |
| 3 |
|
| 4 |
`Plack <https://metacpan.org/release/Plack>`__ is a powerful engine that |
| 5 |
powers many very fast `servers <http://plackperl.org/#servers>`__. LLNG |
| 6 |
uses some Plack libraries to run as FastCGI server. So, It can be easily |
| 7 |
run on these servers. See also :doc:`Advanced PSGI usage<psgi>` if you |
| 8 |
want to replace LLNG FastCGI server. |
| 9 |
|
| 10 |
Complete example |
| 11 |
---------------- |
| 12 |
|
| 13 |
.. code-block:: perl |
| 14 |
|
| 15 |
#!/usr/bin/perl |
| 16 |
|
| 17 |
use Data::Dumper; |
| 18 |
use Plack::Builder; |
| 19 |
|
| 20 |
# Basic test app |
| 21 |
my $testApp = sub { |
| 22 |
my ($env) = @_; |
| 23 |
return [ |
| 24 |
200, |
| 25 |
[ 'Content-Type' => 'text/plain' ], |
| 26 |
[ "Hello LLNG world\n\n" . Dumper($env) ], |
| 27 |
]; |
| 28 |
}; |
| 29 |
|
| 30 |
# Build protected app |
| 31 |
my $test = builder { |
| 32 |
enable "Auth::LemonldapNG"; |
| 33 |
$testApp; |
| 34 |
}; |
| 35 |
|
| 36 |
# Build portal app |
| 37 |
use Lemonldap::NG::Portal::Main; |
| 38 |
my $portal = builder { |
| 39 |
enable "Plack::Middleware::Static", |
| 40 |
path => '^/static/', |
| 41 |
root => '/path/to/portal/htdocs/'; |
| 42 |
Lemonldap::NG::Portal::Main->run( {} ); |
| 43 |
}; |
| 44 |
|
| 45 |
# Build manager app |
| 46 |
use Lemonldap::NG::Manager; |
| 47 |
my $manager = builder { |
| 48 |
enable "Plack::Middleware::Static", |
| 49 |
path => '^/static/', |
| 50 |
root => '/path/to/manager/htdocs/'; |
| 51 |
enable "Plack::Middleware::Static", |
| 52 |
path => '^/doc/', |
| 53 |
root => '/path/to/dir/that/contains/"doc"'; |
| 54 |
enable "Plack::Middleware::Static", |
| 55 |
path => '^/lib/', |
| 56 |
root => '/path/to/doc/pages/documentation/current/'; |
| 57 |
Lemonldap::NG::Manager->run( {} ); |
| 58 |
}; |
| 59 |
|
| 60 |
# Global app |
| 61 |
builder { |
| 62 |
mount 'http://test1.example.com/' => $test; |
| 63 |
mount 'http://auth.example.com/' => $portal; |
| 64 |
mount 'http://manager.example.com/' => $manager; |
| 65 |
}; |
| 66 |
|
| 67 |
Launch it with `Starman <https://github.com/miyagawa/Starman>`__ for |
| 68 |
example: |
| 69 |
|
| 70 |
:: |
| 71 |
|
| 72 |
$ starman --port 80 --workers 32 llapp.psgi |
| 73 |
|