Icinga-Web und nGINX Rewrite Rules
Um Icinga-Web auch unter nGinx zu nutzen, muss man ein wenig in die Trickkiste greifen und die Requests umschreiben. Leider führte das Tutorial von Andis Blog nicht zu einem funktionierenden Ergebnis.
Voraussetzung ist: Icinga-Web ist unter /opt/icinga installiert:
server {
server_name HIER_DEIN_SERVERNAME;
listen 80;
root /opt/icinga/pub;
location /icinga-web/styles {
alias /opt/icinga/pub/styles;
}
location /icinga-web/images {
alias /opt/icinga/pub/images;
}
location /icinga-web/js {
alias /opt/icinga/lib;
}
location /icinga-web/modules {
rewrite ^/icinga-web/(.*)$ /index.php?/$1 last;
}
location /icinga-web/web {
rewrite ^/icinga-web/(.*)$ /index.php?/$1 last;
}
location / {
# HINT: Das Verzeichnis wo die index.php ist
root /opt/icinga/pub;
index index.php;
location ~* ^/(robots.txt|static|images) {
break;
}
if ($uri !~ "^/(favicon.ico|robots.txt|static|index.php)") {
rewrite ^/([^?]*)$ /index.php?/$1 last;
}
}
location ~ \.php($|/) {
include /opt/nginx/conf/fastcgi_params;
fastcgi_pass 127.0.0.1:9001;
fastcgi_param SCRIPT_FILENAME /opt/icinga/pub$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
}
}