Forum Discussion
How to add a query string value to pass to servers in teh pool?
I would like to add a query string value to the incoming http request to distinguish on the server if it is coming in on an ssl virtual or not.
Example 1
From
https://www.somedomain.com/somepage.aspx
To
https://www.somedomain.com/somepage.aspx?issecure=y
OR
From
https://www.somedomain.com/somepage.aspx?someothername=800
To
https://www.somedomain.com/somepage.aspx?someothername=800&issecure=y
Anyone have some input to how we cold do this. I am an iRule novice.
- Steve_Brown_882Historic F5 AccountHaving issues with a similare irule wondering if anyone has thoughts.
- Steve_Brown_882Historic F5 AccountTo provie a litte more feedback when I change the code to add this
if { ($content starts_with "/print/") and ($content ends_with "?") } {
- The_Bhattman
Nimbostratus
Can you provide an example of what the original uri looks like and what you want it to look like after its been appended? - Steve_Brown_882Historic F5 Accountbasically I am looking to append it something along the lines of "&sometest=something" The uri will look something like /print/sometstuff/ and may or may not have an existing query string hence the conditions. I also tried appending the HTTP::query and then appending the HTTP:uri with [HTTP::path][HTTP::query] with the same result.
- hoolio
Cirrostratus
stjbrown, the value for HTTP::uri and most other HTTP:: commands is cached within the same iRule event. You can see the updated value by adding a second HTTP_REQUEST event with a priority that triggers after the defautl priority of 500:when HTTP_REQUEST { set query_args "p1=v1" log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]" if { [HTTP::uri] ends_with "?" } { http://www.foo.com/bar? -> http://www.foo.com/bar?p1=v1 HTTP::uri "[HTTP::uri]$query_args" } elseif { [HTTP::uri] contains "?" } { http://www.foo.com/bar?a=b -> http://www.foo.com/bar?a=b&p1=v1 HTTP::uri "[HTTP::uri]&$query_args" } else { http://www.foo.com/bar -> http://www.foo.com/bar?p1=v1 HTTP::uri "[HTTP::uri]?$query_args" } } when HTTP_REQUEST priority 501 { log local0. "[IP::client_addr]:[TCP::client_port]: (501) Updated URI: [HTTP::uri]" }
- Steve_Brown_882Historic F5 AccountThanks for the follow up, but this still does not seem to function as I would expect. Basically everything works accept it I never see and actual & logged. So for the example above if the entered URL were "http://www.foo.com/bar" It is changed to "http://www.foo.com/bar?p1=v1" just fine. However if the URL is "http://www.foo.com/bar?a=b" I get this in the logs. "http://www.foo.bar?a=bp1=v1". Notice the missing & in the second example. I tried eascabing the & with a backslash, but no luck.
- hoolio
Cirrostratus
An initial request of http://www.foo.com/bar?a=b should match this clause:} elseif { [HTTP::uri] contains "?" } { http://www.foo.com/bar?a=b -> http://www.foo.com/bar?a=b&p1=v1 HTTP::uri "[HTTP::uri]&$query_args"
when HTTP_REQUEST { set query_args "p1=v1" log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] request to [HTTP::host][HTTP::uri]. Appending $query_args." if { [HTTP::uri] ends_with "?" } { http://www.foo.com/bar? -> http://www.foo.com/bar?p1=v1 HTTP::uri "[HTTP::uri]$query_args" log local0. "[IP::client_addr]:[TCP::client_port]: URI ends with ?" } elseif { [HTTP::uri] contains "?" } { http://www.foo.com/bar?a=b -> http://www.foo.com/bar?a=b&p1=v1 HTTP::uri "[HTTP::uri]&${query_args}" log local0. "[IP::client_addr]:[TCP::client_port]: URI contains ?" } else { http://www.foo.com/bar -> http://www.foo.com/bar?p1=v1 HTTP::uri "[HTTP::uri]?$query_args" log local0. "[IP::client_addr]:[TCP::client_port]: URI does not contain ?" } } when HTTP_REQUEST priority 501 { log local0. "[IP::client_addr]:[TCP::client_port]: (501) Updated URI: [HTTP::uri]" }
- Tosin_Omojola
Altostratus
I have a similar situation but slightly different in the sense that my query parameters is quite different from the one above.
http://10.10.1.57:9001/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks
The intended uri is what I have above but, I want clients to access http://10.10.1.57:9001/ and be directed to
http://10.10.1.57:9001/forms/frmservlet?config=ref&serveruserparams=NLS_LANG=AMERICAN_AMERICA.AR8MSWIN1256&otherparams=P_WST_LAN_IND=1+P_BANKS_APP_URL=http://10.10.1.57:9001/banks
That is the full query string that should accessed.
Please note that 10.10.1.57:9001 is the virtual IP and it is load-balanced to the pool thereafter.
I've answered this question in OP other post: https://devcentral.f5.com/s/feed/0D51T00006j41ULSAY
 
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