Assuming you're on 9.2.5 or higher, you have the fix for CR64809 which allows sending binary data from an iRule using HTTP::respond.
Take a look at this post for details on how to create a datagroup which contains the base64 encoded binary data of the PDF file (
Click here). Name the datagroup pdf_404_file. As noted in that post, the content of the PDF file is loaded in memory, so don't use a large source file or you'll impact the memory TMM has available to function.
Once you have the datagroup defined, you can use a rule like this to send a default PDF to the client if they request a PDF and get a 404 from the application:
Create a datagroup containing the base64 encoded binary data from a PDF:
http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=9523
when RULE_INIT {
Log debug messages to /var/log/ltm? 1=yes, 0=no
set ::pdf_404_debug 1
}
when HTTP_REQUEST {
Don't check response status by default
set check_response_status 0
if {[string tolower [HTTP::path]] ends_with ".pdf"}{
Request was for a PDF, so check response status
set check_response_status 1
Log debug
if {$::pdf_404_debug}{log local0. "Received request for a pdf: [IP::client_addr] -> [HTTP::host][HTTP::uri]"}
}
}
when HTTP_RESPONSE {
Check if response was a 404 and request was for a PDF
if {[HTTP::status] == 404 and $check_response_status}{
Log a debug message
if {$::pdf_404_debug}{log local0. "404 response received. Sending default PDF for [IP::client_addr]"}
Respond with the default PDF binary data
HTTP::respond 200 content [b64decode [lindex $::pdf_404_file 0]] "Content-Type" "application/pdf"
}
}
Aaron