Forum Discussion
LTM iRule to direct traffic
For an F5 10200 LTM running 12.1.0
Have an iRule redirecting all port 80 traffic to port 443 on VIP vip.abc.com. Need to make an exception to allow traffic to one IIS website to go through on port 80 while still enforcing port 443 for the other websites.
Ideas much appreciated. I am an iRule novice.
- Vijay_ECirrus
You would have to integrate this logic into the existing iRule, if any:
when HTTP_REQUEST { if { [HTTP::host] eq "domain.com" } { pool POOL_domain_80 } else { HTTP::respond 301 Location "https://vip.abc.com" } }
POOL_domain_80 has pool members listening on port 80.
- David__PaschAltostratus
Try this:
when HTTP_REQUEST { if { not ([string tolower [HTTP::path]] starts_with "/non-secure-IIS-site") } { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } }
Be sure to have a :80 pool configured behind the port :80 VIP.
Good Luck!
- Nick_T1Nimbostratus
Both of the existing answers make assumptions about your code. It would be helpful if you provided the current iRule as-is or with any necessary substitutions for scrubbing.
- aaperson_255899Nimbostratus
Nothing fancy. I'm using the F5 built in irule named _sys_https_redirect when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
- Nick_T1Nimbostratus
Gotcha. I think that David's answer is likely what you need then. You're going to be replacing the built in rule with a slightly modified version of that default rule to allow the 80 traffic to flow through unaffected
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