0

I'm trying to configure IcingaWeb2 using Nginx, and having some issues with it. The suggested Icinga Nginx configuration is:

location ~ ^/icingaweb2/index\.php(.*)$ {
  # fastcgi_pass 127.0.0.1:9000;
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  include 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 works fine, but let's the web on /icingaweb2/ while I want it on /. If I just remove icingaweb2/ from the conf, it works fine for every URL but /.

My current configuration is:

server {
    listen 443 ssl default_server;

    server_name example.com
    ssl_certificate cert_path;
    ssl_certificate_key cert_key;

    location ~ ^/index\.php(.*)$ {
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
      include 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 ~ ^/(.*)? {
     alias /usr/share/icingaweb2/public;
     index index.php;
     try_files $1 $uri $uri/ /index.php$is_args$args;
    }
}

This works perfectly fine if I try, for example, to access https://example.com/dashboard but fails only for https://example.com/ with a 403 error. I have also tried to configure a specific location / {} doing a redirect o rewrite to /dashboard but still getting a 403.

Any idea of what can I try next?

3

I fix it putting a rewrite on the second location.

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

It doesn't feel like the best... but now all is working as expected.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.