Forum Discussion
GaryZ_31658
Mar 28, 2006Historic F5 Account
Change Referer on inbound HTTP::header
I have an application that monitors the "Referer" in the header very specifically.
I need to change "https://domain.com/uri?important_server_data" TO "http://domain.com/uri?important_server_data"
Unfortunately, on each call, the "?important_server_data" changes.
Here is what I have:
when HTTP_REQUEST {
set refer [HTTP::header "Referer"]
set refer_var [findstr $refer "https://" 8 ":"]
if { [HTTP::header exists "Referer"] } {
HTTP::header replace "Referer" "http://$refer_var"
log local0. "refer_var=$refer_var"
}
}
I am not certain what the delimiter is (how far to go when extracting the data for refer_var.
In any case, this is not working very well... Any suggestions?
TIA
GaryZ
- I'd just use the TCL builtin "string range" command to extract the content you want from the original referrer (you can specify a start index and end of string for the stopping point). Something like this should do the job:
when HTTP_REQUEST { set referer [HTTP::header "Referer"] if { $referer starts_with "https://" } { log local0. "Found Referer header: $referer" set newReferer "http://[string range $referer 8 end]" log local0. "Changing Referer header to $newReferer" HTTP::header replace "Referer" $newReferer } }
- GaryZ_31658Historic F5 AccountJoe,
- Great to hear!
- mmishtoon_57736
Nimbostratus
Hello All, - hoolio
Cirrostratus
I'm not sure the referer is the answer. For your first question, the browser sets the Referer header value. I'm not aware of any method for the application (or LTM) to instruct the client to set the referer header value for another request to any value. If it were possible, it would probably be a security concern. If you wanted to include some identifier in your application that the other app could reference, maybe you could add a query string parameter with some kind of referrer ID: - mmishtoon_57736
Nimbostratus
Hello Aaron, - hoolio
Cirrostratus
Hi Marcus,
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