honeybee
Goto Top

Apache + Icinga Web 2: Automatische URL-Umleitung

Hallo,

ich habe Icinga 2 inkl. Icinga Web 2 unter CentOS 8 installiert.

Nun möchte ich, dass die URL "servername.domain.com/icingaweb2" automatisch zu "servername.domain.com" umgeleitet wird und dass man auch Icinga Web 2 öffnen kann, wenn man einfach nur die URL "servername.domain.com" aufruft. Geht das?

Die momentane Apache-Config für Icinga Web 2 sieht so aus:
Alias /icingaweb2 "/usr/share/icingaweb2/public"  

<Directory "/usr/share/icingaweb2/public">  
    Options SymLinksIfOwnerMatch
    AllowOverride None

    DirectoryIndex index.php

    <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAll>
            Require all granted
        </RequireAll>
    </IfModule>

    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from all
    </IfModule>

    SetEnv ICINGAWEB_CONFIGDIR "/etc/icingaweb2"  

    EnableSendfile Off

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

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

</Directory>

HTTPS ist standardmäßig aktiviert. Es gibt eine Anleitung in der Icinga 2-Doku, aber dort hat es bei mir nicht geklappt und außerdem ist dort nur HTTP: https://icinga.com/docs/icinga-web-2/latest/doc/20-Advanced-Topics/#virt ...

Content-Key: 1148963356

Url: https://administrator.de/contentid/1148963356

Printed on: April 27, 2024 at 10:04 o'clock

Member: mshm17
Solution mshm17 Aug 12, 2021 at 14:59:32 (UTC)
Goto Top
Moin,

leg dir einfach eine Config für servername.domain.com an und mach ein redirect auf servername.domain.com/icinga2

Gruß
Member: honeybee
honeybee Aug 13, 2021 at 07:29:02 (UTC)
Goto Top
Hallo,

gibt es eine Config als Beispiel, wie sowas aussehen muss?

mach ein redirect auf servername.domain.com/icinga2
Denn irgendetwas versteh ich nicht: warum auf "servername.domain.com/icinga2"?

Momentan muss man folgende URL eingeben, um Icinga Web 2 aufzurufen:
und ich möchte das so haben:
Member: honeybee
honeybee Aug 13, 2021 at 09:59:16 (UTC)
Goto Top
Hab es nun doch hingekriegt:

  • in /etc/httpd/conf.d/httpd.conf:
    Listen 433
    statt
    Listen 80
  • /etc/httpd/conf.d/ssl.conf in "ssl.conf.bak" umbenannt
  • neue Config erstellt:
    <VirtualHost *:443>
        ServerName servername.domain.com
    
        ## Vhost docroot
        # modified for Icinga Web 2
        DocumentRoot "/usr/share/icingaweb2/public"  
    
        ## Rewrite rules
        RewriteEngine On
    
        SSLEngine on
        SSLProtocol all -SSLv2 -SSLv3
        SSLCertificateFile /etc/pki/tls/certs/servername.domain.com.cer
        SSLCertificateKeyFile /etc/pki/tls/private/servername.domain.com.key
    
        <Directory "/usr/share/icingaweb2/public">  
    
            Options SymLinksIfOwnerMatch
            AllowOverride None
    
            DirectoryIndex index.php
    
            <IfModule mod_authz_core.c>
                <RequireAll>
                    Require all granted
                </RequireAll>
            </IfModule>
    
            SetEnv ICINGAWEB_CONFIGDIR "/etc/icingaweb2"  
    
            EnableSendfile Off
    
            <IfModule mod_rewrite.c>
                RewriteEngine on
                RewriteBase /
                RewriteCond %{REQUEST_FILENAME} -s [OR]
                RewriteCond %{REQUEST_FILENAME} -l [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^.*$ - [NC,L]
                RewriteRule ^.*$ index.php [NC,L]
    
                RewriteCond %{HTTP_HOST} !^servername\.domain\.com [NC]
                RewriteCond %{HTTP_HOST} !^$
                RewriteRule ^/(.*) https://servername.domain.com/$1 [L,R]
            </IfModule>
    
            <IfModule !mod_rewrite.c>
                DirectoryIndex error_norewrite.html
                ErrorDocument 404 /icingaweb2/error_norewrite.html
            </IfModule>
    
        </Directory>
    
    </VirtualHost>
    
    <VirtualHost *:80>
            ServerName servername.domain.com
            ServerAlias servername
            Redirect permanent / https://servername.domain.com/
    </VirtualHost>