Skip to content

Instantly share code, notes, and snippets.

@lazyfrosch
Created May 10, 2013 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lazyfrosch/5553017 to your computer and use it in GitHub Desktop.
Save lazyfrosch/5553017 to your computer and use it in GitHub Desktop.
Nginx Config I got from a user for Icinga*
server {
server_name myhost;
listen 80;
root /usr/share/icinga-web/pub;
if ($http_host != "myhost") {
rewrite ^ http://myhost$request_uri permanent;
}
location = /favicon.ico {
log_not_found off;
access_log off;
expires max;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location /icinga-web/styles {
alias /usr/share/icinga-web/pub/styles;
}
location /icinga-web/images {
alias /usr/share/icinga-web/pub/images;
}
location /icinga-web/js {
alias /usr/share/icinga-web/lib;
}
location /icinga-web/modules {
rewrite ^/icinga-web/(.*)$ /index.php?/$1 last;
}
location /icinga-web/web {
rewrite ^/icinga-web/(.*)$ /index.php?/$1 last;
}
location /icinga-web {
root /usr/share/icinga-web/pub;
index index.php;
location ~* ^/(robots.txt|static|images) {
break;
}
if ($uri !~ "^/(favicon.ico|robots.txt|static|index.php)") {
rewrite ^/icinga-web/([^?]*)$ /index.php?/$1 last;
}
}
## pnp4nagios >>>
location /pnp4nagios {
alias /usr/share/pnp4nagios/html;
auth_basic "Restricted";
auth_basic_user_file /etc/icinga/htpasswd.users;
}
location /pnp4nagios/image {
rewrite ^/pnp4nagios/image(.*)$ /pnp4nagios/index.php/image$1 last;
}
location ~ ^(/pnp4nagios.*\.php)(.*)$ {
root /usr/share/pnp4nagios/html;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
fastcgi_pass 127.0.0.1:9000;
}
## <<<
location ~ \.php($|/) {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME /usr/share/icinga-web/pub$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
location /icinga {
alias /usr/share/icinga/htdocs;
index index.html;
auth_basic "Restricted";
auth_basic_user_file /etc/icinga/htpasswd.users;
}
location /icinga/stylesheets {
alias /etc/icinga/stylesheets;
}
location /icinga/images {
alias /usr/share/icinga/htdocs/images;
}
location ~ \.cgi$ {
# define root directory for CGIs
root /usr/lib/cgi-bin/icinga;
rewrite ^/icinga/cgi-bin/(.*)\.cgi /$1.cgi break;
rewrite ^/cgi-bin/icinga/(.*)\.cgi /$1.cgi break;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/fcgiwrap.socket;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
auth_basic "Restricted";
auth_basic_user_file /etc/icinga/htpasswd.users;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
}
location ~ ^/icinga-api/(.+\.php)$ {
root /usr/share/icinga/htdocs;
try_files $uri = 404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
auth_basic "Restricted";
auth_basic_user_file /etc/icinga/htpasswd.users;
fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment