For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

RyanF5_169352's avatar
RyanF5_169352
Icon for Nimbostratus rankNimbostratus
Jul 28, 2015

X-Forwarder to redirect external access to webpage to https

I'm definitely new to irules and codes so bare with me. I'm trying to come up with an irule in the LTM that will allow me to have internal clients to a webpage clear text(http), while redircting external clients to https. Here's the irule I having problems with. I keep getting an error with the "ne" when reffering to my data group list for the inside rfc1918. Any help would be appreciated!

when HTTP_REQUEST { log local0. "X-Forwarded-For: [HTTP::header "X-Forwarded-For"]"

            foreach xff [split [string map [list " " ""] [HTTP::header "X-Forwarded-For"]] ","] {
                log local0. "Current XFF element: $xff"

             if {[class match $xff ne private_net]}{
                HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
                }
             }

}

2 Replies

  • Try

    if { not ( [class match $xff equals private_net] ) } {
        HTTP::redirect "https://[getfield [HTTP::host] ":" 1][HTTP::host]"
    }
    

    So curiously, are you always going to get an XFF header in the request? What would you do if you didn't?

  • Have two virtual server 1 for servicing and HTTPS (443) traffic and another for HTTP traffic. On HTTP traffic virtual server configure the iRule to redirect external users to HTTPS virtual server.