Hi. I had the following problem: the browser couldn't update the status page
because of the connection problem between the browser and HAProxy. Instead
the browser showed the last page it had managed to fetch. This can be
problematic as a quick glance tells you that everything is OK and you don't
realize that there's a connection problem.
I solved this problem by creating a frameset that contains one frame with
the following JavaScript and five other frames containing HAProxy status
pages.
<script type="text/javascript" language="JavaScript">
// Refreshes this frame once an hour just in case there a memory leak
(maybe this is unnecessary)
setInterval("window.open('lb_refresher.html', '_self')", 3600000);
// Define HAProxys' URLs
var LB = [];
LB[1] = 'dummyurl01.com';
LB[2] = 'dummyurl02.com';
LB[3] = 'dummyurl03.com';
LB[4] = 'dummyurl04.com';
LB[5] = 'dummyurl05.com';
function refreshStatusframe(i) {
// Add a time stamp to the url to avoid cacheing
var now = new Date();
parent.frames[i].location.href = 'https://' + LB[i] +
'/stats/haproxy?timestamp=' + now.toString().replace(/\ /g, '_');
}
// Populate status frames and set automatic refreshing
for (var i=1; i<5; i++) {
refreshStatusframe(i); // Load the status frame
immediately
// Randomize refresh intervals to avoid concurrent load peaks
setInterval(eval('"refreshStatusframe(' + i + ')"'), 59000 +
Math.floor(Math.random() * 2000))
}
</script>
Now if there should be a connection problem the browser is forced to display
a page-not-found. And after the connection returns the frame is populated
with the status page again at latest within a minute. HAProxy is configured
to the status page every 10 s and the script above doesn't interfere with
that.
I hope this helps someone with the same problems I had. If so, enjoy.