Forum Discussion

Jim_Couch_16225's avatar
Jim_Couch_16225
Icon for Nimbostratus rankNimbostratus
Jan 27, 2015

iRule to redirect HTTPs to a third party URL

I've tried several of the examples for iRule redirects but I am not having much luck. Basically, when public traffic comes to a VIP on the F5 on port https, I want to be able to read what the original URL was and redirect it to a third party URL out on the internet. Preferrably, I would like the clients URL to change from our site to the external sites URL. (see iRule below)

I set up a VIP (HTTPS) and am using a defalt client ssl and server ssl profiles. In my iRule (that I borrowed and modified from devcentral) I look from traffic with a HTTP_REQUEST that contains our URL and redirect https to our link on surveymonkey.

Ultimately we might have multiple surveys and so I would like to use this same iRule on the same VIP so that no matter what the client types, I can redirect it to the right place. I tested, with CURL, from the F5 and surveymonkey responds. So, I know I can get there from the F5. But when I try to hit my VIP from a client, I just get the spinning wheel. I do know its looking at the iRule because I am using the tolower command and it converts my text from mixed case to lowercase. However, it never changes the URL in my browser to the surkeymonkey URL that is needed.

when HTTP_REQUEST {
   if { (([HTTP::host] contains "myurl.com") or ([HTTP::host] contains "my-url.com")) } {
       HTTP::redirect "https://www.surveymonkey.com/oursurvey]"
     }
   }

5 Replies

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    Jim - could it simply be the rogue ] at the end of oursurvey? I've tested it in my lab and it works.

     

  • When you say it works, does it actually "rewrite" the URL in your browser? I guess it could be that bracket, I'll have to test. Very interesting and thank you.

     

    • nathe's avatar
      nathe
      Icon for Cirrocumulus rankCirrocumulus
      Yes, rewrites URL and takes me to survey monkey site
  • So, the ] turned out to just be sloppy copy/pasting (and editing out the real details of the iRule) but you pointed me in a great direction. What I realized is that it is case sensitive. In another sample I am using the tolower but it doesnt seem to work. But if I type in the MyUrl.com exactly like I am matching then I get the redirect. So, I am pasting a better example in hopes that you know what I am missing with the tolower portion.

    when HTTP_REQUEST {
       if { (([string tolower [HTTP::host]] contains "My-Survey.com") or ([string tolower [HTTP::host]] contains "MySurvey.com")) } {
           HTTP::redirect "https://www.surveymonkey.com/s/MySurvey"
         }
       }
    
  • LOL, actually.. I realize my stupidity.. I was lowering the case but trying to match on something that had multicase.

     

    So, it works HTTP.. now I just need to see if I can get it working with HTTPS

     

    Thank you again