Riverbed Stingray steelapp, displaying a image on a maintenance page

232 views Asked by At

We have setup our application on riverbed stingray, one of the requirement was for us to display a maintenance page when the administrator wants to update the system.

So for this we created a html page with a logo image and uploded both the .html and .png image to the Extra File/ miscellaneous path. We created a rule, in the rule we added below trafficScript that has the hardcoded html file name uploaded to the miscellaneous path. And now with this when i try to access my website it displays the maintenance page, but the image added in the maintenance page is not displayed. But if i dont hardcode the .html file name but use the http.getPath() and then from that get the file name and use for navigation(commented in the script), image is also displayed fine.

If anyone can please point me where if there is any problem or if there is a better way to do this.

  <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Sorry</title>
</head>
<body>
    <img src="/.extra/test.png">
    <h1>Our apologies</h1>
    We're sorry.  All of our operators are busy.  Please try again later.  
</body>
</html>

The TrafficScript

#$url = http.getPath(); 
#if( ! string.regexmatch( $url, "^/\\.extra/(.*)$" ) ) {  
#   break;  
#} else {  
#   $file = $1;  
#}

$file = "App_Offline.html";
# If the file does not exist, stop  
if( ! resource.exists( $file ) ) break;  

# Serve the file from the conf/extra directory  
$contents = resource.get( $file );  
http.sendResponse( "200 OK", "text/html", $contents, "" ); 
1

There are 1 answers

0
ARV On BEST ANSWER

i am now able to display the image on the html page and navigate all the traffic to this page when the rule is enabled. I modified the trafficscript as below

$url = http.getPath();  
if( ! string.regexmatch( $url, "^/\\.extra/(.*)$" ) ) {    
  http.setPath("/.extra/App_Offline.html");  
}  

$url = http.getPath();  

if( ! string.regexmatch( $url, "^/\\.extra/(.*)$" ) ) {    
  break;    
} else {    
  $file = $1;    
}  

# If the file does not exist, stop    
if( ! resource.exists( $file ) ) break;    

$mimes = [    
        "html"  => "text/html",    
        "jpg"    => "image/jpeg",    
        "jpeg"  => "image/jpeg",    
        "png"    => "image/png",    
        "gif"    => "image/gif",    
        "js"    => "application/x-javascript",    
        "css"    => "text/css"  ,    
        "ico"    => "image/x-icon" ,    
        "txt"    => "text/plain"    
        ];    
        if( string.regexmatch( $file , ".*\\.([^.]+)$" ) ) {    
            $mime = $mimes[ $1 ];    
        }    
        if( ! $mime ) $mime = "text/html";   

# Serve the file from the conf/extra directory    
$contents = resource.get( $file );    
http.sendResponse( "200 OK", $mime , $contents, "" );