Forum Discussion

Eric_Frankenfie's avatar
Eric_Frankenfie
Icon for Nimbostratus rankNimbostratus
Jul 10, 2014

Serve Status Page with Images on LTM v10.2

We utilize IP ACLs for a number of our virtual servers and need an easy way for users to identify their source IP address so that we can update our data groups. The traffic is a mix of Internet and Intranet, so directing users to what's my IP or IP Chicken will not be sufficient.

This is a simple iRule which serves up an HTML response along with the users' source IP address.

when HTTP_REQUEST {
  HTTP::respond 200 content "You submitted this request from IP Address: [IP::client_addr] "
    }

I would like to add CSS and images to this, but I am having difficulty determining how to accomplish that. Again, we are running LTM version 10.2, so I don't think we can utilize iFiles.

Any help would be greatly appreciated.

4 Replies

  • These examples are over complicating what I am trying to do.

     

    Can I just base64 encode the single image and then reference it in my HTTP::respond?

     

  • Can I just base64 encode the single image and then reference it in my HTTP::respond?

    Of course. The data group is just a place to store the information, but you could just as easily include that "string" directly in the iRule.

    when HTTP_REQUEST {
        if { [HTTP::uri] equals "/myimage.png" } {
            set img "...base64-encoded image data..."
            HTTP::respond 200 content [b64decode $img] "Content-Type" "image/png"
        } else {
            HTTP::respond 200 content "...some HTML that includes an image src tag for /myimage.png..."
        }
    }
    

    Or, if you wanted to get really crazy and not require a second request for the image, you could include the data inline in your HTML response:

    img src="data:image/png;base64,...base64-encoded image..."
    
  • This ultimately resolved my issue. This gives me a simple page with our logo along with the source IP address. The image is embedded in the HTML which does not require to place any additional files on the files system.

    I encoded the image in base 64 using http://www.base64-image.de/. Note that I shortened the base 64 for the purpose of this post.

    This is the iRule

    when HTTP_REQUEST {
      set data " Fiserv Item Processing - Your IP Address ![](\)
    
    
    
    
    You submitted this request from IP Address: [IP::client_addr]
    
    
    " 
      HTTP::respond 200 content $data
    }