Forum Discussion
iRule to deny traffic from local network AND redirect to HTTPS
Hi all, I have this iRule that's currently working to only allow traffic from a network segment if the http request contains a certain uri, I also want it to be redirected from http to HTTPS but I'm not sure how to insert a http::redirect to the current iRule. comments and advice are appreciated :)
when HTTP_REQUEST { if { ([HTTP::uri] contains "inscripcion-web") } then { if { [IP::addr [IP::client_addr] equals 192.168.147.0/24] } then { pool pool_.93y.94_8690_inscripcion-web } else { } } }
13 Replies
- Kevin_Stewart
Employee
Here's a formatted version of the iRule:
when HTTP_REQUEST { if { [HTTP::uri] contains "inscripcion-web" } { if { [IP::addr [IP::client_addr] equals 192.168.147.0/24] } { pool pool_.93y.94_8690_inscripcion-web } else { do nothing } } }So where and when do you want to redirect the user to HTTPS?
- Colin_Walker_12Historic F5 Account
How about something like:
when HTTP_REQUEST { if { ([HTTP::uri] contains "inscripcion-web") and ([IP::addr [IP::client_addr] equals 192.168.147.0/24]) } { if {[TCP::local_port] == "443"} { pool pool_.93y.94_8690_inscripcion-web } else { HTTP::redirect "https://[HTTP::host][HTTP::uri]" } } }Something like that should get what you're looking for, I believe.
Colin
- acgutierrez_123
Nimbostratus
ok, but the inicial request is HTTP, what I want is when the user types http://www.example.com/inscripon-web/ it redirects to https, is that possible with that iRule?
- Colin_Walker_12Historic F5 Account
Yep. What will happen is if a user requests the page on HTTPS (port 443) it will just direct it to the pool as normal. If the request isn't coming in on HTTPS (I.E. not port 443) then it will redirect to the same host and URI combination but using HTTPS.
Is that what you're looking for?
Colin
- acgutierrez_123
Nimbostratus
that's exactly it :) - Colin_Walker_12Historic F5 AccountThen you should be all set. ;)
- acgutierrez_123
Nimbostratus
so it doesn't matter if the pool that the requests are being redirected to is not 443?
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