Forum Discussion
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.
- Kevin_StewartEmployee
There are a few iRules in the codeshare under the topics of "maintenance page" or "image server" that should help here, in the absence of iRules. Here are a few:
https://devcentral.f5.com/wiki/iRules.LTMImageHosting.ashx
https://devcentral.f5.com/wiki/iRules.LTMMaintenancePage.ashx
In both of the above cases, the css, js, or image is base64-encoded into a data group entry and then decoded on the way back out.
- Eric_FrankenfieNimbostratus
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?
- Kevin_StewartEmployee
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..."
- Eric_FrankenfieNimbostratus
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 }
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com