Forum Discussion
APM not rewriting properly
I am trying to setup an APM portal for a call recording product. Everything is working perfectly except we found that one page has some kind of hard coded URL in the HTML. APM is not rewriting it, so on the outside it breaks.
for example, in the HTML javascript portion, there is something like this
document.VXReplay.WaveFileName = "http://internalservername:8080" + strURL;
So obviously this breaks since the user is connecting through the portal externally. What is the best solution to rewrite this? Is there an option in APM? Or do I need to setup an iRule to catch the stream and rewrite the servername to the external DNS name?
3 Replies
- Rene_C_
Nimbostratus
As far as i know, nothing is rewritten per default from the backend.
The cleanest solution would now be that the backend code is changed to something like
document.VXReplay.WaveFileName = "http://" + window.location.hostname + strURL;
If for some reason its not possible to change the backend code or the configuration accordingly, your only chance is to modify the response-stream directly through an iRule.
- Nick_T_68319
Nimbostratus
Ugh yeah, I hate when people code stuff like that. We are trying to get the vendor to update the code, but I don't know if it will be possible. So I was looking into modifying the response-stream, but how do you append that long URL that APM adds f5w.....? Is that some kind of session id?
- Rene_C_
Nimbostratus
Wouldnt it be sufficient to just rewrite the http://internalservername:8080 with the current hostname?
So some iRule like this:
when HTTP_REQUEST { Don't allow data to be chunked so we can correctly replace payload below if { [HTTP::version] eq "1.1" } { if { [HTTP::header is_keepalive] } { HTTP::header replace "Connection" "Keep-Alive" } HTTP::version "1.0" } save host set hostname [HTTP::host] } when HTTP_RESPONSE { collect response data if { [HTTP::header exists "Content-Length"] } { set content_length [HTTP::header "Content-Length"] } else { set content_length 4294967295 } if { $content_length > 0 } { HTTP::collect $content_length } } when HTTP_RESPONSE_DATA { if { $::patch_apple_and_banana } { set find "http://internalservername:8080" set replace "https://$hostname" set offset 0 set diff [expr [string length $replace] - [string length $find]] Get indices of all instances of find string in the payload set indices [regexp -all -inline -indices $find [HTTP::payload]] foreach idx $indices { set start [expr [lindex $idx 0] + $offset] set end [expr [lindex $idx 1] + $offset] set len [expr {$end - $start + 1}] replace the instance of find with the contents of replace HTTP::payload replace $start $len $replace modify offset if the replace string is larger or smaller than find. incr offset $diff } } }(based on this site)
Though i'm not sure if you really should inspect any response that's coming through; But i guess you get the point.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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