Forum Discussion
adrian_1812
Nimbostratus
Apr 30, 2007Fetching content from external source
Howdy All
Is there anyway to fetch content from an external source, to determine what to do with it?
ie go get http://182.168.0.1/page.aspx?ip=1.1.1.1
and then act on the...
Jon_Strabala_46
Nimbostratus
Jan 21, 2010Aron,
Can you explain what are you trying to do by making an out of band request to a pool? Are you determining if the client request is valid? Or something else?
Actually I want to do a lookup from an external HTTP (RESTful) server to get a Mobile Phone Number (MDN) from the IP of the requesting client e.g. "/[IP::client_addr]" these mobile phones route through the F5 to the internet at large.
Yes it is an out-of-band socket connection to a 3rd host - but in the event the 3rd host is down or it fails to provide a valid MDN then the out-of-band operation does nothing and the out-of-band logic should be ignored.
Future Work: If I couldn't look up the MDN I might re-try the out-of-band operation again once each 30 seconds as long as the connection is up.
Future Work: Once I have an MDN (if and only if I have one) then I might do some HTML injection on the response or a redirect.
Here is some proposed code - hopefully it will work any advice?
when CLIENT_ACCEPTED {
flag as new request needing lookup
set lookup 1
set flag to indicate if we had a valid lookup.
set keyfound 0
}
when HTTP_REQUEST {
if {$lookup == 1} {
we are doing a 3rd host out-of-band lookup
save original request
set req [HTTP::request]
inject a lookup URI in place of original request
HTTP::uri "/[IP::client_addr]"
set pool to lookup server pool called "mdn_lookup"
hopefully the pelow "pool mdn_lookup" is not sticky
such that the later HTTP::retry $req done in the
HTTP_RESPONSE_DATA will not go back to this pool, I
can not set it to another "normal" pool after this
out-of-band processing is done as the requests are
going to the internet at large (not servers under
my control).
pool mdn_lookup
}
}
when HTTP_RESPONSE {
if {$lookup == 1 }{
collect first response (from lookup server) only
HTTP::collect
if {[HTTP::status] == 200} {
200 OK we got an IP lookup from the RESTful server
we have to have a valid MDN or MobileNumber, all other
responses imply no lookup.
collect first response (from lookup server) only
HTTP::collect $clength
valid lookup we have a MDN and can do something with it
set keyfound 1
}
}
normal path for NOT out-of-band responses
}
when HTTP_RESPONSE_DATA {
Once the lookup is done there is NO pool to go back to
as the clients are mobile phones going out to the internet
if {$keyfound == 1} {
set mdn [HTTP::payload]
log local0. "mdb_lookup gives <<$mdn>>"
we want to actually do something with it later but
this iRULE is a proof of concept. Typical we would
alter the true response based on the mdn we just set.
If we never get a valid MDN we the request will
proceed as if the out-of-band lookup never happened.
} else {
log local0. "mdb_lookup gives NULL"
}
HTTP::retry $req
NO ERROR CHECKING YET ....
if mdn_lookup is dead/non-existant I just want to
process things as if there was no out-of_band code
re-set flag so that subsequent response to re-tried
request from real server is not processed as an MDN
lookup - eventually I might put in retry every 15
second logic until we get a valid lookup
set lookup 0
}
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
