Icinga2 seems to work and successfully using ido_mysql but I can't get Icingaweb2 working

Thanks in advance for reviewing my dilemma. I believe I’ve got icinga2 working just fine using ido_mysql. Please see the attached jpegs as a reference for the type of install i’m trying to accomplish.

For reference here’s all the features in icinga2 I have enabled ->

[user@ije00897 ~]# icinga2 feature list
Disabled features: compatlog debuglog elasticsearch gelf graphite icingadb influxdb livestatus opentsdb perfdata statusdata syslog
Enabled features: api checker command ido-mysql mainlog notification
[user@ije00897 ~]#

My hosts are all RHEL7 hosts. My php environment is PHP7.4.4 installed via the remi repos. Php is served via Nginx using PHP-FPM. My nginx version is ->

[root@ije00897 ~]# nginx -v
nginx version: nginx/1.17.9
[root@ije00897 ~]#

Here are all the php and ZendFramework modules installed via yum ->
[ije00897 ~]# yum list installed | grep php
icingaweb2-vendor-lessphp.noarch 2.7.3-1.el7.icinga
php.x86_64 7.4.4-1.el7.remi
php-Icinga.noarch 2.7.3-1.el7.icinga
php-ZendFramework.noarch 1.12.20-1.el7
php-ZendFramework-Auth-Adapter-Ldap.noarch
php-ZendFramework-Cache-Backend-Apc.noarch
php-ZendFramework-Cache-Backend-Libmemcached.noarch
php-ZendFramework-Cache-Backend-Memcached.noarch
php-ZendFramework-Captcha.noarch 1.12.20-1.el7
php-ZendFramework-Db-Adapter-Firebird.noarch
php-ZendFramework-Db-Adapter-Mysqli.noarch
php-ZendFramework-Db-Adapter-Pdo.noarch
php-ZendFramework-Db-Adapter-Pdo-Mssql.noarch
php-ZendFramework-Db-Adapter-Pdo-Mysql.noarch
php-ZendFramework-Db-Adapter-Pdo-Pgsql.noarch
php-ZendFramework-Dojo.noarch 1.12.20-1.el7
php-ZendFramework-Feed.noarch 1.12.20-1.el7
php-ZendFramework-Ldap.noarch 1.12.20-1.el7
php-ZendFramework-Pdf.noarch 1.12.20-1.el7
php-ZendFramework-Search-Lucene.noarch
php-ZendFramework-Serializer-Adapter-Igbinary.noarch
php-ZendFramework-Services.noarch 1.12.20-1.el7
php-ZendFramework-Soap.noarch 1.12.20-1.el7
php-ZendFramework-extras.noarch 1.12.20-1.el7
php-ZendFramework-full.noarch 1.12.20-1.el7
php-bcmath.x86_64 7.4.4-1.el7.remi
php-cli.x86_64 7.4.4-1.el7.remi
php-common.x86_64 7.4.4-1.el7.remi
php-devel.x86_64 7.4.4-1.el7.remi
php-fedora-autoloader.noarch 1.0.1-2.el7
php-fpm.x86_64 7.4.4-1.el7.remi
php-gd.x86_64 7.4.4-1.el7.remi
php-intl.x86_64 7.4.4-1.el7.remi
php-json.x86_64 7.4.4-1.el7.remi
php-ldap.x86_64 7.4.4-1.el7.remi
php-mbstring.x86_64 7.4.4-1.el7.remi
php-mysqlnd.x86_64 7.4.4-1.el7.remi
php-pdo.x86_64 7.4.4-1.el7.remi
php-pdo-dblib.x86_64 7.4.4-1.el7.remi
php-pdo-firebird.x86_64 7.4.4-1.el7.remi
php-pear.noarch 1:1.10.10-4.el7.remi
php-pecl-apcu.x86_64 5.1.18-1.el7.remi.7.4
php-pecl-apcu-bc.x86_64 1.0.5-3.el7.remi.7.4
php-pecl-apcu-devel.x86_64 5.1.18-1.el7.remi.7.4
php-pecl-igbinary.x86_64 3.1.2-1.el7.remi.7.4
php-pecl-imagick.x86_64 3.4.4-9.el7.remi.7.4
php-pecl-interbase.x86_64 1.0.0~DEV.20190523-4.el7.remi.7.4
php-pecl-mcrypt.x86_64 1.0.3-1.el7.remi.7.4
php-pecl-memcache.x86_64 4.0.5.2-1.el7.remi.7.4
php-pecl-memcached.x86_64 3.1.5-1.el7.remi.7.4
php-pecl-msgpack.x86_64 2.1.0-1.el7.remi.7.4
php-pecl-zip.x86_64 1.18.0-1.el7.remi.7.4
php-pgsql.x86_64 7.4.4-1.el7.remi
php-process.x86_64 7.4.4-1.el7.remi
php-soap.x86_64 7.4.4-1.el7.remi
php-sodium.x86_64 7.4.4-1.el7.remi
php-xml.x86_64 7.4.4-1.el7.remi

The Nginx host configuration is ->

server {
listen 80;
listen [::]:80;
server_name blah.blah;
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
include /etc/nginx/snippets/self-signed.conf;
include /etc/nginx/snippets/ssl-params.conf;
include /etc/nginx/snippets/brotli.conf;
add_header Strict-Transport-Security “max-age=63072000; includeSubdomains; preload”;
server_name blah.blah;
index index.php;
root /ast/icingaweb2/public;
error_log /var/log/nginx/error.log;

 location = /favicon.ico {
      log_not_found off;
      access_log off;
      expires max;
 }

 location = /robots.txt {
      allow all;
      log_not_found off;
      access_log off;
 }

 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 fastcgi_params;
      try_files $uri =404;
      fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/run/php-fpm/www.sock;
      fastcgi_param SCRIPT_FILENAME /ast/icingaweb2/public/index.php;
      fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
      fastcgi_param REMOTE_USER $remote_user;
 }

 location ~ ^/icingaweb2/index\.php(.*)$ {
      fastcgi_pass unix:/run/php-fpm/www.sock;
      fastcgi_index index.php;
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME /ast/icingaweb2/public/index.php;
      fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
      fastcgi_param REMOTE_USER $remote_user;
 }

 location ~ ^/icingaweb2(.+)? {
      alias /ast/icingaweb2/public;
      index index.php;
      try_files $1 $uri $uri/ /icingaweb2/index.php$is_args$args;
 }

}

I have setup icingaweb2 manually using the instructions at icinga.com/docs/icingaweb2/latest/doc/20-Advanced-Topics/t . The problem is … when I visit .blah.blah.com/info.php I see ->

Fatal error : Uncaught ErrorException: Uncaught Zend_Controller_Dispatcher_Exception: Invalid controller specified (error) in /usr/share/icingaweb2/library/vendor/Zend/Controller/Dispatcher/Standard.php:244 Stack trace: #0 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(56): Zend_Controller_Dispatcher_Standard->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) #1 /usr/share/icingaweb2/library/vendor/Zend/Controller/Front.php(937): Icinga\Web\Controller\Dispatcher->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) #2 /usr/share/php/Icinga/Application/Web.php(300): Zend_Controller_Front->dispatch(Object(Icinga\Web\Request), Object(Icinga\Web\Response)) #3 /usr/share/php/Icinga/Application/webrouter.php(99): Icinga\Application\Web->dispatch() #4 /ast/icingaweb2/public/index.php(4): require_once(’/usr/share/php/…’) #5 {main} Next Zend_Controller_Exception: Invalid controller specified (error)#0 /usr/share/php/Icinga/Web/Controller/Dispatcher.php(56): Zend_Controller_Dispatcher_Standard->d in /usr/share/icingaweb2/library/vendor/Zend/Controller/Plugin/Broker.php on line 259

Any ideas where I’ve goobered this up? Many thanks in advance

Hi James,

Is this the complete NGINX Configuration, just asking … is there any other active nginx config left (mostly default config maybe) …

If you can re-affirm that’s all config you have i can try to rebuild the setup and see where the nginx config doesn’t work properly.

Regards

David

My solution at this point, cause you haven’t answered yet.

Is the following i’ve used an centos 7 vagrant box so there shouldn’t be a problem with rhel to reproduce it at this point.

Relatively plain install:

yum install epel-release -y
yum install centos-release-scl -y
yum update -y
yum install nginx -y
yum install rh-php71-php-fpm -y
sed -i 's/=enforcing/=permissive/g' /etc/selinux/config
setenforce 0 <= just for the actual session
rpm --import https://packages.icinga.com/icinga.key
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
yum install icingaweb2 -y
mv /etc/nginx/nginx.conf /etc/nginx/nginx.old
==> Here a small inbetween step the rh-php71-php-fpm daemon needs to run for the fpm-uri 
systemctl enable rh-php71-php-fpm --now && netstat -tulpn | grep php-fpm
icingacli setup config webserver nginx --document-root /usr/share/icingaweb2/public --config /etc/icingaweb2 --fpm-uri 127.0.0.1:9000 > /etc/nginx/nginx.conf

This Above just creates a base block of nginx config … there is still missing the essential part.

The base block looks like this:

 location ~ ^/icingaweb2/index\.php(.*)$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   include /etc/nginx/fastcgi_params;   <== this can change and needs adjustment
   fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb2/public/index.php;
   fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
   fastcgi_param REMOTE_USER $remote_user;
  }

  location ~ ^/icingaweb2(.+)? {
    alias /usr/share/icingaweb2/public;
    index index.php;
    try_files $1 $uri $uri/ /icingaweb2/index.php$is_args$args;
  }

With an Editor of you choice you need to add the following parts:

events {
  worker_connections  1024;  ## Default: 1024
}

http {

server {
 listen 80;
 root /usr/share/icingaweb2/public;
}

Just for the example i choose http not https.

So the whole nginx.conf block looks finalized like this:

events {
  worker_connections  1024;  ## Default: 1024
}

http {

server {
 listen 80;
 root /usr/share/icingaweb2/public;

 location ~ ^/icingaweb2/index\.php(.*)$ {
   fastcgi_pass 127.0.0.1:9000;
   fastcgi_index index.php;
   include /etc/nginx/fastcgi_params;
   fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb2/public/index.php;
   fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
   fastcgi_param REMOTE_USER $remote_user;
  }

  location ~ ^/icingaweb2(.+)? {
    alias /usr/share/icingaweb2/public;
    index index.php;
    try_files $1 $uri $uri/ /icingaweb2/index.php$is_args$args;
  }
}

}

This should be validated with the nginx validator:

nginx -t -c /etc/nginx/nginx.conf
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

I hope this helps with finding the error.

Regards

David

1 Like