Forum Discussion
Getting HTML Page Title for iRule
Hi All,
I am working on creating a new VIP with 2 servers(each server has its separate pool).
One of the server have some issues and at times it directly through a Logout Page while accessing app page.
As per app owner he wants to move traffic from one pool to other depending upon the HTML title page in HTTP Response Header.
EX: If page Title is "XYZ" then move traffic to Pool-B and for all other Page title keep traffic to Pool-A.
I suppose this could be achieved by an iRule but I am not able to fetch the HTML Title Page from HTTP Response Header.
Can you pls help me here with the right configuration of iRule.
Thanks in Advance.
Hello, I believe this might be done much easier by implementing a HTTP monitor on pool members, where you can check HTTP response content.
Monitor will automatically mark the node offline if anything but expected content is seen.
To achieve redirect, you can use something like the following iRule
when CLIENT_ACCEPTED { if { [active_members http_pool] = 0 } { pool redirect_pool } }
- Deepak_Kumar2Nimbostratus
,
Thanks for you response, I have already tried health monitor but it does not fulfill the requirement.
Whenever the issue happens on Server in Pool-A it is still responding with 200 OK(desired received string) so F5 does not mark it down.
That's why I have come across with solution HTMP page title but now I am not sure how to fetch it from HTTP Response Header.
Also I am open to any other suggestions.
Hello, sorry for insisting but I still believe a simple way to achieve it would be a properly tuned monitor + irule redirect.
What I meant was checking specific response string instead of just the 200-OK HTTP code.
Configure monitor to check the specific URI and set as your response string something that is uniquely contained in your expected page, so that monitor fails if it's not found (meaning that logout redirect is seen).
When testing monitor, check it against a working server and then against the "problematic" server while you are in the redirect situation, and check what responses are, then confirm monitor fails when "bad page" is seen.
You can test your monitor like this: (echo -e " <monitor string> ";sleep 1) | openssl s_client -connect <server ip>:<server port>
eg
(echo -e "GET /myapplication/ HTTP/1.1\r\nHost: \r\nConnection: Close\r\n\r\n";sleep 1) | openssl s_client -connect 10.10.10.10:443
Another way to do so would be a two-monitor configuration for the pool, and have the second monitor configured with a receive-disable-string so that if monitor sees logout page content in response it marks the pool member down, which would trigger irule redirect.
Hope this helps
CA
The title of the HTML page isn't part of any HTTP header. It's part of the document that's being returned by the webserver. So you'll need to enable the STREAM profile and use it to parse the response. The iRule below shows how to extract the title.
when HTTP_REQUEST { # Disable the stream filter by default STREAM::disable # LTM does not uncompress response content, so if the server has compression enabled # and it cannot be disabled on the server, we can prevent the server from # sending a compressed response by removing the compression offerings from the client HTTP::header remove "Accept-Encoding" } when HTTP_RESPONSE { # Check if response type is text if {[HTTP::header value Content-Type] starts_with "text"} { # match <title>...</title> STREAM::expression {=<title>[A-Za-z0-9\.\-]+==} # Enable the stream filter for this response only STREAM::enable } } when STREAM_MATCHED { # extract the title set title [string range [STREAM::match] 7 end] log local0.info "Title: $title" }
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