# NagVis Apache2 sample configuration file
#
# #############################################################################

Alias @NAGVIS_WEB@ "@NAGVIS_PATH@"

<Directory "@NAGVIS_PATH@">
  Options FollowSymLinks
  AllowOverride None

  <IfModule mod_authz_core.c>
    # Apache >= 2.4
    Require all granted
  </IfModule>
  <IfModule !mod_authz_core.c>
    # Apache < 2.4
    Order allow,deny
    Allow from all
  </IfModule>

  # To enable Nagios basic auth on NagVis use the following options
  # Just uncomment it. Maybe you need to adjust the path to the
  # Auth user file.
  #
  # If you use the NagVis internal auth mechanism based on the web
  # for you won't need this.
  #
  #AuthName "NagVis Access"
  #AuthType Basic
  #AuthUserFile @NAGIOS_PATH@/etc/htpasswd.users
  #Require valid-user
  
  # With installed and enabled mod_rewrite there are several redirections
  # available to fix deprecated and/or wrong urls. None of those rules is
  # mandatory to get NagVis working.
  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase @NAGVIS_WEB@
    
    # Use mod_rewrite for old url redirection even if there are php files which
    # redirect the queries itselfs. In some cases the mod_rewrite redirect
    # is better than the php redirect.
    #
    # Using the php redirect seems to be better in some cases where https/http servers
    # are mixed. For example in OMD setups where using apache own mode and https in the
    # frontend and http in the backend apache servers.
    #
    # Disabling this redirect by default in the hope that the php direct works better.
    #RewriteCond %{REQUEST_URI} ^@NAGVIS_WEB@(/config\.php|/index\.php|/|)(\?.*|)$
    #RewriteRule ^(.*)$ @NAGVIS_WEB@/frontend/nagvis-js/%1%2 [R=301,L]
    
    # Redirect old regular map links
    RewriteCond %{REQUEST_URI} ^@NAGVIS_WEB@/frontend/(wui|nagvis-js)
    RewriteCond %{QUERY_STRING} map=(.*)
    RewriteRule ^(.*)$ @NAGVIS_WEB@/frontend/nagvis-js/index.php?mod=Map&act=view&show=%1 [R=301,L]

    # Without map= param
    RewriteCond %{REQUEST_URI} ^@NAGVIS_WEB@/frontend(/wui)?/?(index.php)?$
    RewriteRule ^(.*)$ @NAGVIS_WEB@/frontend/nagvis-js/index.php [R=301,L]

    # Redirect old rotation calls
    RewriteCond %{REQUEST_URI} ^@NAGVIS_WEB@/frontend/nagvis-js
    RewriteCond %{QUERY_STRING} !mod
    RewriteCond %{QUERY_STRING} rotation=(.*)
    RewriteRule ^(.*)$ @NAGVIS_WEB@/frontend/nagvis-js/index.php?mod=Rotation&act=view&show=%1 [R=301,L]
  </IfModule>
</Directory>

