Page 1 of 2

Accessing NagVis direct via URL

Posted: Wed Oct 23, 2013 10:37 pm
by Fred Kroeger
I would like to access the NagVis maps directly without having to login to Nagios first - eg: URL Links in a portal to display each map.
I was thinking that I create a cname for the Nagios server and connect via that cname and authenticate as the guest user automatically.

To do this requires some entries in the htppd conf file for nagvis but I just have not been able to get it working correctly for the existing nagios server and also connecting via the cname. Is anyone able to point me in the right direction?

regards... Fred

Re: Accessing NagVis direct via URL

Posted: Thu Oct 24, 2013 9:05 am
by slansing
What changes have you made? Can you link the tutorial that you used?

Re: Accessing NagVis direct via URL

Posted: Thu Oct 24, 2013 6:55 pm
by Fred Kroeger
I found this reference.
http://www.monitoring-portal.org/wbb/in ... tID=132884
If you follow down the thread, someone did what I am trying to do with Virtual Hosts.
It should connect automatically as the guest user if you access it via the Virtual Host address.
Any other connections via the Nagios server address will still result in a login prompt.

This is their nagvis.conf file

Code: Select all

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined


        Alias /nagvis "/var/www/nagvis/share"

        <Directory "/var/www/nagvis/">
                AuthName "NagVis Administration"
                AuthType Basic
                AuthUserFile /etc/apache2/htpasswd.users
                Require valid-user
                AllowOverride None
        </Directory>
</VirtualHost>
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName nagvis.domain1.de

        DocumentRoot /var/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

        SetEnv REMOTE_USER gast
        RequestHeader set Cookie "nagvis_session=1"

        Alias /nagvis "/var/www/nagvis/share"
</VirtualHost>

Re: Accessing NagVis direct via URL

Posted: Fri Oct 25, 2013 12:09 pm
by abrist
What version of apache are you using (there are some syntax differences between versions)?

Code: Select all

$(which httpd) -v

Re: Accessing NagVis direct via URL

Posted: Tue Oct 29, 2013 8:42 pm
by Fred Kroeger
It's the standard CentOS 6.3 VM build from Nagios

Server version: Apache/2.2.15 (Unix)
Server built: Feb 13 2012 22:31:42

Re: Accessing NagVis direct via URL

Posted: Wed Oct 30, 2013 10:56 am
by lmiltchev
Autologin in NagVis is not a very good idea but if you need to do this, you can follow the steps outlined in this post:

http://support.nagios.com/forum/viewtop ... vis#p46978

Hope this helps.

Re: Accessing NagVis direct via URL

Posted: Wed Nov 13, 2013 10:06 pm
by Fred Kroeger
Sorry for the delay - I posted a reply to this some time ago and just discovered it was never added?

Anyway - I only want to auto login as Guest user when Nagvis is accessed directly via the CNAME .
All other access is via the Nagios server address which should prompt for a login.

So in effect I want one URL to autologin as guest and another URL to work as it does now.

Regards.. Fred

Re: Accessing NagVis direct via URL

Posted: Thu Nov 14, 2013 11:53 am
by abrist
Fred, are we dealing with this issue in the ticketing system?

Re: Accessing NagVis direct via URL

Posted: Tue Nov 19, 2013 2:44 am
by Fred Kroeger
Only via this forum that I'm aware of?

Re: Accessing NagVis direct via URL

Posted: Tue Nov 19, 2013 5:29 pm
by abrist
Alright, this is working on my test box. You will need to replace the ServerNames: "nagiosxi.localdomain" and "nagiosxinagvis.localdomain" with your two different dns names. One will autologin to nagvis as guest, while the other will prompt with a username/password for nagvis. This still will have the shortcomings of basic auth - if you login to nagvis on the basic auth virtualhost, that login will persist until the cache is cleared (like core). This will not interrupt the autologin of the guest account on the other virtualhost. So beware: any machine you login to nagvis through the basic auth virtualhost will stay logged in for that virtual host until 30 days or a browser cache clear, whichever comes first.

So to recap:
1. Make sure to remove any .htaccess files in the /usr/local/nagvis folders.
2. You will need to replace the ServerNames: "nagiosxi.localdomain" and "nagiosxinagvis.localdomain" in the vhost file below (/etc/httpd/conf.d/nagvis) with your two different dns names.
3. Make sure the new dns names have entries in /etc/hosts and that they are mapped to the nagios xi server ip.
4. Verify that the two following directives are configured in /usr/local/nagvis/etc/nagvis.ini.php:

Code: Select all

logonmodule="LogonMixed"
logonenvvar="PHP_AUTH_USER"
/etc/httpd/conf.d/nagvis.conf:

Code: Select all

# NagVis Apache2 split auth virtualhosts
#
# #############################################################################

NameVirtualHost *:80

#GUEST VIRTUALHOST 
<VirtualHost *:80>

ServerName nagiosxinagvis.localdomain

Alias /nagvis "/usr/local/nagvis/share"

<Directory "/usr/local/nagvis/share">
  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  Allow from all

  SetEnv PHP_AUTH_USER guest

  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /nagvis

    RewriteCond %{REQUEST_URI} ^/nagvis(/index\.php|/|)(\?.*|)$
    RewriteRule ^(index\.php|)(\?.*|)$ /nagvis/frontend/nagvis-js/$1$2 [R=301,L]
    RewriteCond %{REQUEST_URI} ^/nagvis/config\.php.*$
    RewriteRule ^config\.php(.*) /nagvis/frontend/wui/$1 [R=301,L]

    # Redirect old regular map links
    RewriteCond %{REQUEST_URI} ^/nagvis/frontend/nagvis-js
    RewriteCond %{QUERY_STRING} map=(.*)
    RewriteRule ^(.*)$ /nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=%1 [R=301,L]

    # Redirect old wui map links
    RewriteCond %{REQUEST_URI} ^/nagvis/frontend/wui
    RewriteCond %{QUERY_STRING} map=(.*)
    RewriteRule ^(.*)$ /nagvis/frontend/wui/index.php?mod=Map&act=edit&show=%1 [R=301,L]

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

  </IfModule>
</Directory>
</VirtualHost>

#BASIC AUTH VIRTUALHOST
<VirtualHost *:80>

ServerName nagiosxi.localdomain

Alias /nagvis "/usr/local/nagvis/share"

<Directory "/usr/local/nagvis/share">
  Options FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all

  AuthName "NagVis Access"
  AuthType Basic
  AuthUserFile /usr/local/nagiosxi/etc/htpasswd.users
  Require valid-user

  <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /nagvis

    RewriteCond %{REQUEST_URI} ^/nagvis(/index\.php|/|)(\?.*|)$
    RewriteRule ^(index\.php|)(\?.*|)$ /nagvis/frontend/nagvis-js/$1$2 [R=301,L]
    RewriteCond %{REQUEST_URI} ^/nagvis/config\.php.*$
    RewriteRule ^config\.php(.*) /nagvis/frontend/wui/$1 [R=301,L]

    # Redirect old regular map links
    RewriteCond %{REQUEST_URI} ^/nagvis/frontend/nagvis-js
    RewriteCond %{QUERY_STRING} map=(.*)
    RewriteRule ^(.*)$ /nagvis/frontend/nagvis-js/index.php?mod=Map&act=view&show=%1 [R=301,L]

    # Redirect old wui map links
    RewriteCond %{REQUEST_URI} ^/nagvis/frontend/wui
    RewriteCond %{QUERY_STRING} map=(.*)
    RewriteRule ^(.*)$ /nagvis/frontend/wui/index.php?mod=Map&act=edit&show=%1 [R=301,L]

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

  </IfModule>
</Directory>
</VirtualHost>