Forum Discussion
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
- Kevin_Stewart
Employee
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?
- Guru_Palanisamy
Nimbostratus
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.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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