Forum Discussion
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...
- AubreyKingF5Moderator
Have you used log statements to verify expected variable inputs in each section of the iRule? That is the first thing I'd do.
- grmanikantanAltostratus
Hi AubreyKing,
Thanks for your response.
While updating this irule, i got below messages...
01070151:3: Rule [/Common/irule-test] error: /Common/irule-test:4: error: [undefined procedure: internal_call_and_respond][internal_call_and_respond]
/Common/irule-test:7: error: [command is not valid in the current scope][proc internal_call_and_respond {} {
set backend_response [HTTP::get "https://www.myexternal.com"]
set response_status [HTTP::status]
set response_headers [HTTP::header]
}]grmanikantan Based on the log it seems like the subroutine isn't configured properly. Before we go any further with this, what's the requirement that is forcing you to have to take care of this on the F5?
grmanikantan - If your post was solved it would be helpful to the community to select *Accept As Solution*.
This helps future readers find answers more quickly and confirms the efforts of those who helped.
Thanks for being part of our community.
Lief
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