Skip to content

Instantly share code, notes, and snippets.

@lucabrunox
Created June 19, 2014 08:09
Show Gist options
  • Save lucabrunox/1b803c6e249b50f63eab to your computer and use it in GitHub Desktop.
Save lucabrunox/1b803c6e249b50f63eab to your computer and use it in GitHub Desktop.
Nginx, Nagios, NixOS
services.nagios4.cgiConfigFile = pkgs.writeText "nagios.cgi.conf" ''
main_config_file=${cfg.mainConfigFile}
use_authentication=1
url_html_path=${cfg.urlPath}
authorized_for_system_information=lethalman
authorized_for_system_commands=lethalman
authorized_for_configuration_information=lethalman
authorized_for_all_hosts=lethalman
authorized_for_all_host_commands=lethalman
authorized_for_all_services=lethalman
authorized_for_all_service_commands=lethalman
'';
services.nginx.httpConfig = ''
server {
listen 0.0.0.0 ssl;
server_name somename;
ssl_certificate some.crt;
ssl_certificate_key some.key;
auth_basic "Restricted";
auth_basic_user_file ${htpasswdFile};
location ~ ^${cfg.urlPath}/(.+\.php)(.*)$ {
include ${pkgs.nginx}/conf/fastcgi_params;
fastcgi_split_path_info ^${cfg.urlPath}/(.+\.php)(.*)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME ${pkgs.nagios4}/share/$fastcgi_script_name;
fastcgi_param REMOTE_USER $remote_user;
fastcgi_index index.php;
}
location ${cfg.urlPath} {
alias ${pkgs.nagios4}/share;
}
location ~ ^${cfg.urlPath}/cgi-bin/.*\.cgi$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_split_path_info ^${cfg.urlPath}/cgi-bin/(.+\.cgi)(.*)$;
fastcgi_param SCRIPT_FILENAME ${pkgs.nagios4}/sbin/$fastcgi_script_name;
fastcgi_param NAGIOS_CGI_CONFIG ${cfg.cgiConfigFile};
fastcgi_param REMOTE_USER $remote_user;
include ${pkgs.nginx}/conf/fastcgi_params;
}
}
'';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment