2

I currently have icinga2 set up with the new icingaweb2 ui. it defaults to the subfolder /icingaweb as follows:

location ~ ^/icingaweb/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/icingaweb/public/index.php;
    fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb;
}

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

If I change the first location block to:

location / {

it shows the login page minus all css.

How can I get it to work off a subdomain ex. icinga.example.com?

For the record the rest of the file I know is formated correctly such as server_name listen root etc.

Thanks in advance.

Server block as requested:

server {

    listen 80;
    server_name icinga.example.com;
    root /usr/share/icingaweb/public;

    location ~ ^/icingaweb/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/icingaweb/public/index.php;
        fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb;
    }

    location ~ ^/icingaweb(.+)? {
        alias /usr/share/icingaweb/public;
        index index.php;
        try_files $1 $uri $uri/ /icingaweb/index.php$is_args$args;
    }
} 
HopelessN00b
  • 53,385
  • 32
  • 133
  • 208

1 Answers1

1

Found a solution here - Nginx redirect failure for icingaweb2

The rewrite line in the second location block is what makes the magic happen.

Something like this should work in your case:

location ~ ^/index\.php(.*)$ {
  fastcgi_pass unix:/var/run/php5-fpm.sock;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb/public/index.php;
  fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb;
}

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