F5中使用irules在页面中显示图片和html

1、显示html

rule http_res_html {
   when HTTP_REQUEST {

     HTTP::respond 200 content "<html><title>Error</title><body>Error!<img src=/image.png></body></html>"

   }

}

 

2、只显示一张图片,先使用base64编码一张图片,然后

rule http_res_base64_image {
   when HTTP_REQUEST {
      HTTP::respond 200 content [b64decode \
         "R0lGODlhfgAHAJH/AP///wAAAMDAwAAAACH5BAEA\
         AAIALAAAAAB+AAcAQAIvhI+hy+0Po5y0BoSz3sn6\
         D4YTR5adiKYqZLbcCseoS2PyjY/1nve+suP9hrJg\
         pgAAOw=="] "Content-Type" "image/gif"
   }
}

 

3、显示图片+html

rule http_res_html_image {

  when HTTP_REQUEST {
      # error condition was true, so respond back to client with html or image(s)
      switch [string tolower [HTTP::path]] {
         /image.png {
            HTTP::respond 200 content [b64decode [lindex $::logo_f5_png_class 0]] "Content-Type" "image/png"}
         default {
            HTTP::respond 200 content "<html><title>Error</title><body>Error!<img src=/image.png></body></html>"}
      }
  }

}

通过判断[HTTP::path]路径返回不同内容

你可能感兴趣的:(html)