VSHELL CSS creation behind proxy failing

Information and discussions relating to the Nagios V-Shell web interface.

VSHELL CSS creation behind proxy failing

Postby lucask » Tue Mar 27, 2012 7:11 am

My server is running behind a proxy. It's own IP is 10.0.0.10. My proxy is configured so that when I surf to example.com, that it fetches the website from my 10.0.0.10 and servers it to me.

The problem that I noticed is that VSHELL seems to generate some files based on ip, like the relative stylsheet and the JQuery. Resulting in this in the source code in my browser:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head profile="http://dublincore.org">
<title>Nagios Visual Shell</title>

<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="schema.DC" href="http://dublincore.org/2008/01/14/dcelements.rdf#" />
<link rel="schema.DCTERMS" href="http://dublincore.org/2008/01/14/dcterms.rdf#" />
<meta name="description" content="Nagios" />
<meta name="keywords" content="Nagios" /> 
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="en" />
<meta name="site" content="Nagios" />

<link rel="stylesheet" href="http://10.0.0.10/vshell/css/style.css" type="text/css" media="screen" />
<style type="text/css">
<!-- use external stylesheet to control page style -->
</style>

<script type="text/javascript" src="http://10.0.0.10/vshell/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="http://10.0.0.10/vshell/js/header.inc.js"></script>
<script type="text/javascript">
$(document).ready(function() {
  // Handler for .ready() called.
   hide();
});
</script>

</head>
<body>
   <div id="logoDiv"><a href="index.php"><img src="views/images/vshell.png" /></a></div>
   <div class="corelink">
      <a class="label" href="http://10.0.0.10/nagios3/" target="_blank" title="Access Nagios Core">Access Nagios Core</a>
   </div>
   <div id='clearcache' class='label'>
                     <a href='/vshell/index.php?clearcache=true' title='Clear Cached Data'>Refresh Data
                     </a></div>

   <div class="topnav">
      <ul class="nav"><li class="nav"><a href="index.php" class="nav" rel="internal">Tactical Overview</a></li><li class='nav'><a href='http://10.0.0.10/vshell/index.php?type=hosts' class='nav' rel='internal'>Hosts</a></li><li class='nav'><a href='http://10.0.0.10/vshell/index.php?type=services' class='nav' rel='internal'>Services</a></li><li class='nav'><a href='http://10.0.0.10/vshell/index.php?type=hostgroups' class='nav' rel='internal'>Hostgroups</a></li><li class='nav'><a href='http://10.0.0.10/vshell/index.php?type=servicegroups' class='nav' rel='internal'>Servicegroups</a></li><li class='nav'><a class='nav' onmouseover='showDropdown("confDrop")' onmouseout='hideDropdown("confDrop")' href='javascript:void(0)'>Configurations</a>
      <div onmouseover='showDropdown("confDrop")' onmouseout='hideDropdown("confDrop")' id='confDrop'><ul><li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=hosts_objs'>Hosts</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=services_objs'>Services</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=hostgroups_objs'>Hostgroups</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=servicegroups_objs'>Servicegroups</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=timeperiods'>Timeperiods</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=contacts'>Contacts</a></li>
<li><a class='nav' href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=contactgroups'>Contactgroups</a></li>
<li><a href='http://10.0.0.10/vshell/index.php?type=object&objtype_filter=commands' class='nav'>Commands</a></li>
</ul></div></li><li class='nav'><a class='nav' onmouseover='showDropdown("sysDrop")'
            onmouseout='hideDropdown("sysDrop")' href='javascript:void(0)'>System Commands</a>
            <div onmouseover='showDropdown("sysDrop")' onmouseout='hideDropdown("sysDrop")' id='sysDrop'><ul><li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/extinfo.cgi?type=3'>Comments</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/extinfo.cgi?type=6'>Downtime</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/extinfo.cgi?type=0'>Process Info</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/extinfo.cgi?type=4'>Performance Info</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/extinfo.cgi?type=7'>Scheduling Queue</a></li>
</ul></div></li>
<li class='nav'><a class='nav' onmouseover='showDropdown("reportDrop")'
            onmouseout='hideDropdown("reportDrop")' href='javascript:void(0)'>Reports</a>
            <div onmouseover='showDropdown("reportDrop")' onmouseout='hideDropdown("reportDrop")' id='reportDrop'><ul><li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/avail.cgi'>Availability</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/trends.cgi'>Trends</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/history.cgi?host=all'>Alert History</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/summary.cgi'>Alert Summary</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/histogram.cgi'>Alert Histogram</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/notifications.cgi?contact=all'>Notifications</a></li>
<li><a class='nav' target='_blank' href='http://10.0.0.10/nagios3/cgi-bin/showlog.cgi'>Event Log</a></li>
</ul></div></li>
</ul>
   </div>


<div class="main">
   

<!-- ##################Nagios Info Table################### -->
<div id='infodiv'>

<p class='note'>Nagios V-Shell v1.9.1<br />
   Copyright (c) 2010-2012 <br />
   Nagios Enterprises, LLC. <br />
   Written by Mike Guthrie<br />
   For questions, feedback, <br /> or support, visit the <br />
   <a href='http://support.nagios.com/forum/viewforum.php?f=19' target='_blank'>V-Shell Forum</a>.</p>

</div><br />
<table class='tac'>
<tr><th>Tactical Monitoring Overview</th></tr>
   <tr>
      <td>
         Last Check: Tue Mar 27 14:03 37s<br />
          Nagios® Core™ 3.2.1 - www.nagios.org<br />
         Logged in as nagiosadmin<br />
      </td>
   </tr>
</table>
<br /><div id='meterContainer'><div class='h_container'>Host Health: 100% <br />

               <div class='borderDiv'>
               <div class='healthmeter' style='background: rgb(60,255,0); width: 100%;'>

            </div></div></div>
<div class='h_container'>Service Health: 96.55% <br />

               <div class='borderDiv'>
               <div class='healthmeter' style='background: rgb(72,255,0); width: 96.551724137931%;'>

            </div></div></div>
</div> <!-- end health meters -->

<!-- ########################HOSTS TABLE########################## -->
<table class='tac'>
<tr><th>Hosts</th></tr>
<tr>
   <td class='ok'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=UP'><div class='td'>4 Up</div></a></td>
   <td class='down'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=DOWN'><div class='td'>0 Down</div></a></td>
   <td class='unreachable'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=UNREACHABLE'><div class='td'>0 Unreachable</div></a></td>
   <td class='pending'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=PENDING'><div class='td'>0 Pending</div></a></td>            
   
</tr>
<tr>
   <td class='problem'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=PROBLEMS'><div class='td'>0 Problems</div></a></td>
   <td class='unhandled'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=UNHANDLED'><div class='td'>0 Unhandled</div></a></td>
   <td class='acknowledged'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=hosts&amp;state_filter=ACKNOWLEDGED'><div class='td'>0 Acknowledged</div></a></td>
   <td><div class='td'><a class='highlight' href='index.php?type=hosts' title='All Hosts'>4 Total</div></a></td>
</tr>

</table>
<br />
<!-- ######################SERVICES TABLE##################### -->
<table class='tac'>
<tr><th>Services</th></tr>
   
  <tr>
      <td class='ok'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=OK'><div class='td'>28 Ok</div></a></td>
      <td class='critical'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=CRITICAL'><div class='td'>1 Critical</div></a></td>
      <td class='warning'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=WARNING'><div class='td'>0 Warning</div></a></td>      
      <td class='unknown'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=UNKNOWN'><div class='td'>0 Unknown</div></a></td>
      <td class='pending'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=PENDING'><div class='td'>0 Pending</div></a></td>
  </tr>
  <tr>
   <td class='problem'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=PROBLEMS'><div class='td'>1 Problems</div></a></td>
   <td class='unhandled'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=UNHANDLED'><div class='td'>1 Unhandled</div></a></td>
   <td class='acknowledged'><a class='highlight' href='http://10.0.0.10/vshell/index.php?type=services&amp;state_filter=ACKNOWLEDGED'>0 Acknowledged</a></td>
   <td colspan='2'><a class='highlight' href='index.php?type=services' title='All Services'><div id='td_servicestotal' class='td'>29 Total </div></a></td>
</tr>

</table>
<br />
<!-- #####################ENABLED FEATURES TABLE ####################-->
<table class='tac'>
<tr><th>Monitoring Features</th></tr>
<tr>
   <td>Flap Detection</td><td>Notifications</td><td>Event Handlers</td>
   <td>Active Checks</td><td>Passive Checks</td>
</tr><tr>   

<!-- ///////////////////////FLAPPING//////////////////////////////// -->
   <td class='green'>
      All Hosts Enabled<br />
       All Services Enabled<br />
      No Hosts Flapping<br />
       No Servies Flapping<br />                                                 
   </td>
   
   <!-- /////////////////////////////NOTIFICATIONS/////////////////////////////// -->
   <td class='green'>
      All Hosts Enabled<br />
       All Services Enabled<br />   
   </td>
   
   <!-- ///////////////////////////////EVENT HANDLERS///////////////////////////// -->
   <td class='green'>
      All Hosts Enabled<br />
       All Services Enabled<br />   
   </td>
   
   <!-- /////////////////////////////////ACTIVE/PASSIVE CHECKS///////////////////////////   -->
   <td class='green'>
      All Hosts Enabled<br />
       All Services Enabled<br />         
   </td>

   <td class='green'>
      All Hosts Enabled<br />
       All Services Enabled<br />         
   </td>


</tr>
</table>
<br />

<!-- #####################SEARCH BOX####################-->
<div class='resultFilter'>
   <form id='resultfilterform' action='/vshell/index.php' method='get'>
      <input type='hidden' name='type' value='services'>
      <label class='label' for='name_filter'>Search String</label>
      <input type='text' name='name_filter'></input>
      <input type='submit' name='submitbutton' value='Filter' />
   </form>
</div>
<br /></div> <!--end of "main" div -->

</body>
</html>


As you can see my browser get's the instruction to fetch the css file at the IP of the server (which is a LAN IP) instead of using the domain name.
lucask
 
Posts: 5
Joined: Tue Mar 27, 2012 7:06 am

Re: VSHELL CSS creation behind proxy failing

Postby mguthrie » Tue Mar 27, 2012 10:39 am

My guess is that this is something you'll need to define in your /etc/hosts file. V-Shell gets the address by asking apache first for a server's name, and if it doesn't have one defined, default to an IP address.
mguthrie
 
Posts: 4384
Joined: Mon Jun 14, 2010 10:21 am

Re: VSHELL CSS creation behind proxy failing

Postby lucask » Tue Mar 27, 2012 10:47 am

Why not just use a relative path?
lucask
 
Posts: 5
Joined: Tue Mar 27, 2012 7:06 am

Re: VSHELL CSS creation behind proxy failing

Postby mguthrie » Tue Mar 27, 2012 1:08 pm

Because as far as I know, apache will still plug in the full URL when it makes the actual http request. You're certainly welcome to change the header to use a relative path though and see if that works. Do you have your DNS hostname actually defined on the nagios server itself? We've had this issue with Nagios XI before as well, where a DNS name is used, but the Nagios server itself doesn't know what the DNS entry resolves to. Apache uses the same logic when it checks for the system's host name. If it doesn't find one, it defaults to an IP address.
mguthrie
 
Posts: 4384
Joined: Mon Jun 14, 2010 10:21 am

Re: VSHELL CSS creation behind proxy failing

Postby lucask » Wed Mar 28, 2012 3:04 pm

At the moment I just hard coded my DNS name to make it work. When I have time this weekend I'll look into it to make the paths relative. For the CSS files, a relative path worked. The problem is that some other stuff seemed to break when I just used sed. If I come up with something I'll let you know.
lucask
 
Posts: 5
Joined: Tue Mar 27, 2012 7:06 am

Re: VSHELL CSS creation behind proxy failing

Postby lucask » Fri Mar 30, 2012 5:55 pm

Okay, I had time to take a look at the code.

I made all paths relative, this means the BASEURL is actually obsolete. What I did is not request the servername anymore, but just rely on the folders. Which is essentially the same but just putting the FQDN or the IP upfront. The webserver will know what you want. "/" will be the root of the webserver.

This actually fixes two problems:
    It's working behind a proxy
    The workaround for ssl is obsolete as you will never be redirected to http, also you don't need to keep track of the port anymore

The reason why SSL didn't work is because you always redirected back to http in the links, the workaround fixed, but when using relative paths, this will be handled by the webserver, so you will never exit SSL.

I changed your code, I've put the code on my site (attachement was too large) http://cloud101.eu/files/vshell.patched.tar.gz . I haven't been able to test it 100% yet, but SSL worked for me, and I can make use of the nagios cgi bin to add comments/alerts, also all the relative paths seemed to work.

I suggest you just install it yourself and have a look, if there is any hickup, please feel free to send me an email and I'll get back on it. I really like your project and I hope to use it in a future project of mine with Raspberry Pi.
lucask
 
Posts: 5
Joined: Tue Mar 27, 2012 7:06 am

Re: VSHELL CSS creation behind proxy failing

Postby mguthrie » Mon Apr 02, 2012 9:25 am

Thanks for the notes on this. I'll take a look at the patch, and if all goes well in testing I'll probably go with the relative URL, seem simpler. Thanks for the v-shell blog tutorial by the way :)
mguthrie
 
Posts: 4384
Joined: Mon Jun 14, 2010 10:21 am

Re: VSHELL CSS creation behind proxy failing

Postby lucask » Tue Apr 03, 2012 5:16 am

No problem :)
lucask
 
Posts: 5
Joined: Tue Mar 27, 2012 7:06 am


Return to Nagios V-Shell

Who is online

Users browsing this forum: No registered users and 1 guest