Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

iRule to disable APM and redirect for specific URI

Hi All,

We had a problem where an external website going through APM portal access rewrite won't render properly. So we wrote an iRule to disable access for this paricular resource and redirect to original web URL, which is below:

when HTTP_REQUEST { if { [HTTP::uri] contains "123456789012345678962789346$$/mycompany" } { ACCESS::disable HTTP::redirect "https://test.mycompany.com/mycompany" } }

URI above was captured when APM codes the destination resources in Hex.

iRule above works perfectly but this will only capture one URI and redirect to one specific website. Is there a way that we can make this irule more scalable for example if we have multiple links pointing to multiple external websites, how do we achieve it rather than creating irules for every single link?

Any suggestions or alternative methods to above please!!

Regards,

Ali

0
Rate this Discussion

Replies to this Discussion

placeholder+image

Hi,

You can define split rewrite in the rewrite profile.

0
Comments on this Reply
Comment made 07-Jun-2016 by Ali Khan 57
Hi, Thanks but rewrite is not a scalable option for us as you know we have to define exclude and include list both for it to work. The portal access is for a sharepoint site and contains hundreds of links to different sites and resources. I would turn grey very quickly just to identify all the links to include :) (and we wont be able to define URIs using wildcards either)
0
Comment made 07-Jun-2016 by Stanislas Piron 10481
Did you try in ACCESS_ACL_ALLOWED? In this event, the URL is decoded.
0
Comment made 07-Jun-2016 by Lucas Thompson
The default for rewrite is to NOT rewrite when using a split configuration. You should not rewrite outside sites, only inside sites. This is the intended use case, it sounds like you're describing..
1
Comment made 31-Jan-2017 by Ali Khan 57

Agreed Lucas, but what can you do when your client wants their staff portal to be one stop shop for everything!! Even links to training videos on youtube are on this portal :)

0
placeholder+image

Hi,

you can try this irule:

when HTTP_REQUEST {
    if {[scan [HTTP::uri] {/f5-w-%[^$]$$%s} encressource uri] > 1} {
    set ressource [binary format H* $encressource]
    switch -- [URI::host $ressource] {
        "www.google.fr" -
        "www.youtube.com" -
        "test3.mycompany.com" {  HTTP::respond 302 Location $ressource$uri }
        }
    }
}    
0
Comments on this Reply
Comment made 31-Jan-2017 by Ali Khan 57

Thanks Stanislas, Interesting!!

I will give this a go and update.

0
Comment made 31-Jan-2017 by Stanislas Piron 10481

you can also do it with a data group.

0