【问题标题】:Riverbed Stingray steelapp, displaying a image on a maintenance pageRiverbed Stingray steelapp,在维护页面上显示图像
【发布时间】:2014-06-27 09:47:53
【问题描述】:

我们已经在 Riverbed stingray 上设置了我们的应用程序,其中一项要求是当管理员想要更新系统时我们显示一个维护页面。

为此,我们创建了一个带有徽标图像的 html 页面,并将 .html 和 .png 图像上传到 Extra File/ miscellaneous 路径。我们创建了一个规则,在我们添加到下面的 trafficScript 的规则中,将硬编码的 html 文件名上传到杂项路径。现在,当我尝试访问我的网站时,它会显示维护页面,但不会显示在维护页面中添加的图像。 但是如果我不硬编码 .html 文件名而是使用 http.getPath() 然后从中获取文件名并用于导航(在脚本中注释),图像也可以正常显示。

如果有人可以指出我在哪里有任何问题或者是否有更好的方法来做到这一点。

  <!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>

交通脚本

#$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, "" ); 

【问题讨论】:

    标签: html stingray


    【解决方案1】:

    我现在可以在 html 页面上显示图像,并在启用规则时将所有流量导航到此页面。我修改了交通脚本如下

    $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, "" ); 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-13
      • 1970-01-01
      • 1970-01-01
      • 2017-11-11
      • 2012-09-29
      • 2014-04-14
      相关资源
      最近更新 更多