Skip to content

@kazeburo /nagios_web.psgi
Last active

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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 },
)->to_app;
my $htdocs = Plack::App::PHPCGIFile->new(
root => '/usr/local/nagios/share'
)->to_app;
builder {
enable match_if addr([qw!127.0.0.1!]), '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/([^\.]+/)*$!;
$apps->($env);
};
};
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
Something went wrong with that request. Please try again.