Apache rewrites for pretty custom views?

Hi all!

New here and fairly new to Icinga2, coming from a Nagios/Opsview background however, I’ve been looking at making nicer url’s and possibly have these work with variables to redirect users to custom searches.

For examples:
going to icinga.companydomain.com/dev
should redirect to

Ideally we want to use this a variable to changing dev to “live” would change dev in the actual url to live also but this isn’t required as I don’t mind adding a few differing rules to cover each of our environments.

However no matter where I put the rewrite in the config it doesn’t work, it either breaks icingaweb entirely or it no change seems to be made at all.

the rewrite line im using is:
RewriteRule ^dev$ monitoring/list/services?host=%2A.dev.%2A&service_state!=OK&limit=500&sort=host_display_name&modifyFilter=1 [NC,L]

The rest of the apache config is as follows(standard icingaweb2 conf as far as i can tell), this is our current live config without my edit due to the issues it was causing.
<Directory “/usr/share/icingaweb2/public”>
Options SymLinksIfOwnerMatch
AllowOverride None
SetEnv ICINGAWEB_CONFIGDIR “/etc/icingaweb2”

EnableSendfile Off

<IfModule mod_rewrite.c>
    RewriteCond %{REQUEST_FILENAME} -s [OR]
    RewriteCond %{REQUEST_FILENAME} -l [OR]
    RewriteCond %{REQUEST_FILENAME} -d
    RewriteRule ^.*$ - [NC,L]
    RewriteRule ^.*$ index.php [NC,L]

<IfModule !mod_rewrite.c>
    DirectoryIndex error_norewrite.html
    ErrorDocument 404 /error_norewrite.html

Could anyone give suggestions, I’m hoping I’m just being slow and somethinghasn’t clicked that’s simple but after much searching and confirming the rewrite works on a standard apache host I’m at a slight loss.

Thanks in advance! loving icinga so far and looking to get to know it more

That redirect/rewrite should get its own configuration outside of the icingaweb2 declaration. You’ll likely have an existing VHost as a default listening on 80/443, put it there.


Here is a small and simple guide to build a URL shortener on apache2

Like Michael said put that into a now virtual host.
I would recommend to put apache2 or icingaweb2 to a different port so maybe
and for the shortcuts you can use the normal https url
Or you use https(443) for icingaweb2 and http(80) for the shorts rewrite http to https is normally no problem for the browsers the other way results in some security errors on firefox and chrome thats my experiance

1 Like