Accessing NagVis direct via URL

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Accessing NagVis direct via URL

Post 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
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Accessing NagVis direct via URL

Post by slansing »

What changes have you made? Can you link the tutorial that you used?
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Accessing NagVis direct via URL

Post 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>
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Accessing NagVis direct via URL

Post by abrist »

What version of apache are you using (there are some syntax differences between versions)?

Code: Select all

$(which httpd) -v
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Accessing NagVis direct via URL

Post 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
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Accessing NagVis direct via URL

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Accessing NagVis direct via URL

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Accessing NagVis direct via URL

Post by abrist »

Fred, are we dealing with this issue in the ticketing system?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Fred Kroeger
Posts: 588
Joined: Wed Oct 19, 2011 11:36 pm
Location: Perth, Western Australia
Contact:

Re: Accessing NagVis direct via URL

Post by Fred Kroeger »

Only via this forum that I'm aware of?
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: Accessing NagVis direct via URL

Post 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>
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked