Skip to content

Instantly share code, notes, and snippets.

Last active January 30, 2017 01:38
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save kazeburo/4480122 to your computer and use it in GitHub Desktop.
PSGI file to serving Nagios WebUI
use Plack::App::CGIBin;
use Plack::App::PHPCGIFile;
use Plack::Builder;
use Plack::Builder::Conditionals;
my $cgibin = Plack::App::CGIBin->new(
root => "/usr/local/nagios/sbin",
exec_cb => sub { my $file = shift; $file =~ m!\.cgi$! and -x $file },
my $htdocs = Plack::App::PHPCGIFile->new(
root => '/usr/local/nagios/share'
builder {
enable match_if addr([qw!!]), 'ReverseProxy';
enable sub {
my $apps = shift;
sub {
my $env = shift;
return [302,[Location=>'http://'.$env->{HTTP_HOST}.'/nagios/'],['moved']] if $env->{PATH_INFO} =~ m!^/(nagios)?$!;
$env->{REMOTE_USER} = 'nagiosadmin';
$env->{PATH_INFO} .= 'index.php'
if $env->{PATH_INFO} =~ m!^/nagios/([^\.]+/)*$!;
mount '/nagios/cgi-bin' => $cgibin,
mount '/nagios' => $htdocs,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment