-
-
Save laughingman7743/5089394 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo yum install nagios | |
sudo install -o nagios -g nagios -d /usr/local/nagios/plack | |
cd /usr/local/nagios/plack | |
curl -kL http://cpanmin.us/ | /usr/bin/perl - -n -lextlib Plack \ | |
Plack::App::PHPCGI Plack::Builder::Conditionals \ | |
Plack::Middleware::ReverseProxy CGI::Compile Starlet |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[program:nagios-web] | |
process_name=%(program_name)s | |
command=/usr/bin/perl -Mlib=/usr/local/nagios/plack/extlib/lib/perl5 /usr/local/nagios/plack/extlib/bin/plackup -s Starlet -p 5000 /usr/local/nagios/plack/nagios_web.psgi | |
autostart=true | |
autorestart=true | |
user=nagios | |
redirect_stderr=true | |
stdout_logfile=/var/log/nagios/%(program_name)s.log | |
stdout_logfile_maxbytes=5MB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Plack::App::CGIBin; | |
use Plack::App::PHPCGIFile; | |
use Plack::Builder; | |
use Plack::Builder::Conditionals; | |
my $cgibin = Plack::App::CGIBin->new( | |
root => "/usr/lib64/nagios/cgi-bin", | |
exec_cb => sub { my $file = shift; $file =~ m!\.cgi$! and -x $file }, | |
)->to_app; | |
my $htdocs = Plack::App::PHPCGIFile->new( | |
root => '/usr/share/nagios/html' | |
)->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, | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location /nagios { | |
proxy_pass http://127.0.0.1:5000/nagios; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-Host $host; | |
proxy_set_header X-Forwarded-Server $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_connect_timeout 10; | |
proxy_send_timeout 60; | |
proxy_read_timeout 60; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo chown root.nagios /usr/share/nagios/html/config.inc.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment