Forum Discussion
HELITG_35878
Nimbostratus
Aug 08, 2006iRule for HTTP to HTTPS using a specific pool for a specific virtual directory
Hi everyone,
I'm new to writing irules and I need some guidance on this one.
For a specific virtual directory I want to ensure all visitors use ssl
i.e
for requests to anything beginning http://www.site.com/secure1
I want the uri to be re-written as
https://www.site.com/secure1
and be directed to use a specific pool, say pool1
I was thinking on the lines of
when HTTP::REQUEST {
if ((http_host matches_regex "www.site.com") and (http_uri starts_with "/secure1"))
{
HTTP::redirect https://[HTTP::Host][HTTP::uri]
}
Any help would be appreciated.
Thanks in advance.
- hoolio
Cirrostratus
That looks like a good start as far as logic goes. I would suggest using contains, starts_with or equals instead of matches_regex, unless you really need to use a regular expression to match the hostname as matches_regex is more resource intensive that the string comparisons.if ((http_host equals "www.site.com") and (http_uri starts_with "/secure1")) { redirect to "https://www.site.com" + http_uri }
if (http_uri starts_with "/secure1") { use pool pool1 } else { use pool default_pool }
- HELITG_35878
Nimbostratus
Thanks for the reply. It worked.
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