Skip to content

Instantly share code, notes, and snippets.

@vachanda
Created September 19, 2016 10:15
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save vachanda/377805c5fd4fac8a8db101e99416d601 to your computer and use it in GitHub Desktop.
Save vachanda/377805c5fd4fac8a8db101e99416d601 to your computer and use it in GitHub Desktop.
Nginx config for icinga2 web interface.
server {
listen *:80;
server_name www.icinga2.com;
root /usr/share/icingaweb2/public; #Path of icinga2 web directory
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
location = /favicon.ico {
log_not_found off;
access_log off;
expires max;
}
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~ \..*/.*\.php$ {
return 403;
}
if (!-d $request_filename) {
rewrite ^/(.+)/$ /$1 permanent;
}
location / {
try_files $1 $uri $uri/ /index.php$is_args$args;
}
location ~ ^/index\.php(.*)$ {
fastcgi_index index.php;
include /etc/nginx/fastcgi_params;
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock; #Replace with the port if php fpm is configured to run on port.
fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb2/public/index.php; #Replace with icinga2 web index.php file path.
fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
fastcgi_param REMOTE_USER $remote_user;
}
}
@cancinos
Copy link

cancinos commented Dec 6, 2016

Thanks dude! I was looking for this exactly script!

@Server4001
Copy link

Super helpful!

@KubaNeumann
Copy link

Thanks a lot!

@tdschmidl
Copy link

I had to add following lines to get around long-taking tasks (e.g. schema upgrades from Icinga2 Director)

location ~ ^/index\.php(.*)$ { 
[...]
proxy_connect_timeout 1200s;
proxy_send_timeout 1200s;
proxy_read_timeout 1200s;
fastcgi_send_timeout 1200s;
fastcgi_read_timeout 1200s;
}

@AvnanRahman
Copy link

can be simplified?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment