Forum Discussion
Scott_McCool_11
Nimbostratus
Jun 06, 2007Insert custom header if it does not exist in v4
Is there any way I can insert a new HTTP header in v4 (I understand this is fairly simple in v9) if the header doesn't already exist in the request?
Basically, if MY_CUSTOM_HEADER is already present I want to pass the request along to my pool of webservers. If it isn't present, I want to insert it and set it to the client_addr.
I can use the "header to insert" line on the pool configuration page as: MY_CUSTOM_HEADER:${client_addr}
but I can't seem to find a way to get the header inserted only if it isn't already present (I don't want to overwrite it if it is).
Any ideas? The only thing that comes to mind is something like:
if (http_header("MY_CUSTOM_HEADER") contains "") {
use new_pool_doing_nothing_but_adding_header
}
and then define that new pool with a "header to insert" line; hoping that only requests that didn't have the header are sent there.
Is there a cleaner way? Something I'm overlooking with that approach?
- Colin_Walker_12Historic F5 AccountYou should be able to use the "exists http_header" command to determine if the header is present. You could then forward it to a pool that inserts the header, as you mentioned above.
if( exists http_header "MY_CUSTOM_HEADER" ) { use pool normalPool } else { use pool insertPool }
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