Need help on irule: External content for internal request in F5
I have a requirement and trying to achive through irule but some how not working as expected..
Requirement:
Client to access Internal URL : https://www.abcd.com
F5 to call the content from this external URL: https://www.myexternal.com
Insert external URL content and send back to internal URL as response
I tried this way but not working...
========
when HTTP_REQUEST {
if { [HTTP::host] equals "www.abcd.com" } {
# Call the subroutine to handle the internal request and respond to the client
internal_call_and_respond
}
}
# Subroutine to handle the internal call and response
proc internal_call_and_respond {} {
set backend_response [HTTP::get "https://www.myexternal.com"]
set response_status [HTTP::status]
set response_headers [HTTP::header]
# Set the response status code and headers from the backend response
HTTP::respond $response_status [HTTP::header replace $response_headers] -persist {
# Send the backend response content as the body of the client response
echo $backend_response
}
}
==========
Thanks in advance...