0

Riverbed Stingray にアプリケーションをセットアップしました。要件の 1 つは、管理者がシステムを更新したいときにメンテナンス ページを表示することでした。

そのため、ロゴ画像を含む 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>

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

1 に答える 1

0

ルールが有効になっている場合、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, "" ); 
于 2014-07-03T06:04:11.083 に答える