Forum Discussion

Bart_18836's avatar
Bart_18836
Icon for Nimbostratus rankNimbostratus
Apr 28, 2014

SorryPage with iFiles on 11.3 HF8

Here is my problem, I have uploaded files via "System ›› File Management : iFile List" , created references under "Local Traffic ›› iRules : iFile List" , wrote an iRule for maintenance page and ttached iRule to one of my virtual servers, however it seems that pictures are not loaded at all. Can you have a look and tell me what can be wrong (although all looks ok to me). All object names and file names are exactly the same to avoid mistakes or typeos in code

 

iRule code :

 

when HTTP_REQUEST {  
log local0. "HTTP_REQ: Requested Hostname: [HTTP::host] URI: [HTTP::uri]"
 if { [HTTP::uri] eq "/sp" } {
 switch [HTTP::uri] {
      "/sp" {
           HTTP::respond 200 content [ifile get "index"] "Content-Type" "text/html"
      }
      "/logo" {
           HTTP::respond 200 content [ifile get "logo"] "Content-Type" "image/png"
      }
      "/background" {
           HTTP::respond 200 content [ifile get "background"] "Content-Type" "image/jpeg"
      }
 }
 }
 }   

25 Replies

  • since there is if-statement (HTTP::uri eq /sp) before switch, /logo and /background won't hit the switch-case (because it is not equal to /sp)

    Correct. You should just need to remove the if layer:

    when HTTP_REQUEST {  
        log local0. "HTTP_REQ: Requested Hostname: [HTTP::host] URI: [HTTP::uri]"
        switch [HTTP::uri] {
            "/sp" {
                HTTP::respond 200 content [ifile get "index"] "Content-Type" "text/html"
            }
            "/logo" {
                HTTP::respond 200 content [ifile get "logo"] "Content-Type" "image/png"
            }
            "/background" {
                HTTP::respond 200 content [ifile get "background"] "Content-Type" "image/jpeg"
            }
        }
    }
    
  • So then just to level set, did you remove the initial if { [HTTP::uri] eq "/sp" } evaluation? What does the log statement report? Do you see the request for the /logo URI? How about some additional logging just to make sure:

    when HTTP_REQUEST {  
        log local0. "HTTP_REQ: Requested Hostname: [HTTP::host] URI: [HTTP::uri]"
        switch [HTTP::uri] {
            "/sp" {
                log local0. "catch /sp"
                HTTP::respond 200 content [ifile get "index"] "Content-Type" "text/html"
            }
            "/logo" {
                log local0. "catch /logo"
                HTTP::respond 200 content [ifile get "logo"] "Content-Type" "image/png"
            }
            "/background" {
                log local0. "/catch background"
                HTTP::respond 200 content [ifile get "background"] "Content-Type" "image/jpeg"
            }
        }
    }
    
  • This would suggest that the iRule is working and that perhaps the ifile is not. This is where a client side capture utility like Fiddler or HTTPWatch can be useful. I'm guessing that if you watch the traffic from the client side, you'll actually see a response to the image request, but the returned data won't be useful as an image.