Forum Discussion
IRULE for redirect request (http to https), append request and rewrite response (http to https)
Hello Experts
I want to write irule for below requirement. Please help me out
1- http://www.abc.com/ -> https://www.abc.com/test/login.aspx (http to https and append test/login.aspx to www.abc.com/)
2- https://www.abc.com/ -> https://www.abc.com/test/login.aspx (only append test/login.aspx to www.abc.com/)
3- When I access https://www.abc.com/test/login.aspx, there is some link in httpwatch in response that is http://ajax.googleapis.com. I also want to rewrite this response http://ajax.googleapis.com -> https://ajax.googleapis.com
Regards,
GR
2 Replies
- JRahm
Admin
For 1&2, you can use an httpclass (pre v11.4) or a policy (11.4+) to do that, no iRule necessary.
For 3, google would need to rewrite that ajax call, the request isn't coming to your domain. However, assuming it's your app that is inserting that, you can use a stream profile to rewrite that URL to ssl. You can try this (untested, check out and tune as necessary in lab environment)
when HTTP_RESPONSE { STREAM::disable set stream_expression ""; if { ( ([HTTP::header Content-Type] starts_with "text/html") && ([HTTP::status] == 200) } { set stream_expression "@http://www.youtube.com@@" } if { "" ne $stream_expression } { STREAM::expression $stream_expression STREAM::enable } } when STREAM_MATCHED { if { [string tolower [STREAM::match]] eq “http://www.youtube.com” } { STREAM::replace “https://www.youtube.com” } } - JRahm
Admin
give this a shot:
ltm policy http.redirects { controls { forwarding } requires { http } rules { redirect_rules { actions { 0 { http-reply redirect location https://www.abc.com/test/login.aspx } } conditions { 0 { http-host host values { www.abc.com } } 1 { http-uri values { / } } } ordinal 1 } } strategy all-match }
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