Forum Discussion
Simple iRule with Sticky?
I'm trying to create what I think is a fairly simple iRule:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/sites/tech*" } {
pool Tech_Web_Pool_80
} else {
pool Main_Web_Pool_80
}
}
The issue I have is that the first part of the iRule works. It sends you to the right web pool but the page is missing content because it is trying to load jpegs, png files, and gifs for the buttons etc ... These graphic files are in the /main/images folder which due to iRule above gets sent to the other pool.
Is there a way so that if it matches the first part of the iRule and goes to my Tech_Web_Pool_80 that it then forces the client to retrieve all content and links from that pool?
The main problem is that the /main/images directory exists in both pools but the graphic images are completely different since they are on different versions of our website.
Any help would be appreciated!
Thanks!
James
- hooleylistCirrostratusHi James,
when HTTP_REQUEST { if { [HTTP::uri] contains "/sites/tech" or [HTTP::header Referer] contains "/sites/tech" } { pool Tech_Web_Pool_80 } else { pool Main_Web_Pool_80 } }
- PacketHead_4009NimbostratusThanks Hoolio. I'm unfamiliar with the Referer command. Will this keep that users session all on the Tech_Web_Pool_80 including the request for the images in the other directory?
Also, two other questions:
1.) How do I get it so that it is all non-case sensitive? Right now it doesn't honor sites/Tech or Sites/tech.
2.) And if I have another URL I need to send same Tech Web Pool (say sites/dev) how do I enter it in the iRule so that it will search both before sending to default/else pool?
- hooleylistCirrostratusBrowsers can set the Referer header to indicate which URI generated the current request:
http://tools.ietf.org/html/rfc2616section-14.36 The Referer[sic] request-header field allows the client to specify, for the server's benefit, the address (URI) of the resource from which the Request-URI was obtained (the "referrer", although the header field is misspelled.) The Referer request-header allows a server to generate lists of back-links to resources for interest, logging, optimized caching, etc. It also allows obsolete or mistyped links to be traced for maintenance. The Referer field MUST NOT be sent if the Request-URI was obtained from a source that does not have its own URI, such as input from the user keyboard. http://tools.ietf.org/html/rfc2616section-15.1.3 Clients SHOULD NOT include a Referer header field in a (non-secure) HTTP request if the referring page was transferred with a secure protocol.
when HTTP_REQUEST { Check the requested URI to see if it is a non-default pool request switch -glob [string tolower [HTTP::uri]] { "*/sites/tech*" - "*/uri2/tech*" - "*/uri3/tech*" { pool Tech_Web_Pool_80 } default { No match on the URI, so check the Referer header to see if it is a non-default pool request switch -glob [string tolower [HTTP::header Referer]] { "/sites/tech" - "*/uri2/tech*" - "*/uri3/tech*" { pool Tech_Web_Pool_80 } default { No match on URI or Referer so use the main pool pool Main_Web_Pool_80 } } } } }
- PacketHead_4009NimbostratusNice, thanks Aaron. I was wondering if I was going to have to use glob. I will tweak this for the URIs that I have and see how it works. Thanks!
- PacketHead_4009NimbostratusAlso is there a reason why there are no asterisks on the "sites/tech" line in the Referer portion of the script?
- hooleylistCirrostratusThat was just a typo :) You'll want the wildcards for /sites/tech too.
- PacketHead_4009Nimbostratus
Hello Aaron,
Thanks I placed them in there as I figured they would be needed. All is working well except a few items:
1.) I can't get to the main URL anymore http://mysite. I can browse to http://mysite/sites/tech but it isn't honoring http://mysite/default.aspx
2.) What happens if I have a URL of /sites/technology that needs to go to the Main_Web_Pool_80? Won't the above rule for */sites/tech* automatically send it to the Tech_Web_Pool_80 pool? Do I simply remove the appending * after tech to make the entry more specific so that only /sites/tech would be sent to the Tech_Web_Pool_80?
Any ideas? So far it is working great overall, thanks for the help!
Regards,
James
- hooleylistCirrostratusHi James,
when HTTP_REQUEST { Check the requested URI to see if it is a non-default pool request switch -glob [string tolower [HTTP::uri]] { "/sites/technology*" { Use the main pool pool Main_Web_Pool_80 } "/" - "/default.aspx*" - "*/sites/tech*" - "*/uri2/tech*" - "*/uri3/tech*" { pool Tech_Web_Pool_80 } default { No match on the URI, so check the Referer header to see if it is a non-default pool request Use URI::path and URI::basename to get the URI from the Referer header set referer [string tolower [HTTP::header Referer]] switch -glob "[URI::path $referer][URI::basename $referer]" { "/sites/technology*" { Use the main pool pool Main_Web_Pool_80 } "/" - "/default.aspx*" - "/sites/tech" - "*/uri2/tech*" - "*/uri3/tech*" { pool Tech_Web_Pool_80 } default { No match on URI or Referer so use the main pool pool Main_Web_Pool_80 } } } } }
- PacketHead_4009Nimbostratus
Ok, I need to fire this thread up again. The script that Hoolio provided is working like a champ. Now we are migrating and we are hitting a small issue. First here is the modified version of his iRule:
when HTTP_REQUEST {
"*/sites/webservices*" -
"*/mysite*" {
"*/sites/webservices*" -
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