Forum Discussion

aaperson_255899's avatar
aaperson_255899
Icon for Nimbostratus rankNimbostratus
Nov 08, 2016

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.

 

5 Replies

  • 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.

  • 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!

     

  • 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.

     

  • 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]

     

  • 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