HTTP to HTTPS Redirection

1.) When customers goes directly to

VIP Nation load balancer is not redirecting to VIP Nation

Redirection works for the following though:

iRule being used for this customer is as follows:

when HTTP_REQUEST {

if { ! ([string tolower [HTTP::uri]] starts_with “/livenation/”) } {

HTTP::redirect “VIP Nation”

}

}

Are there anything that I could do to the above iRule so that it would work as expected?

Thank you,

Ram

What exactly do you want it to doWhat exactly do you want it to do? When do you want the redirect to happen?

(edit, after looking more closely at the post)

It looks like you’re doing more than just HTTP to HTTPS redirection, as you’re also modifying the path. What do you want to do if the user uses HTTP but goes to the /livenation/ directory? Should it just redirect to HTTPS and keep the same path, or do you want it to go to the login page?

Basically when customer goes to VIP Nation load balancer should redirect to VIP Nation also like it does for the following:

Thanks,

Ram

It looks like you have the concept down of how to evaluate the requested URI and send a redirect to the client. Now it’s just a matter of deciding what logic to use in implementing the iRules. If you aren’t sure of what you need, try what you have and add logging statements to track what’s happening when it doesn’t work. As it looks like you might being using two different rules on the two VIPs make sure to note which VIP the request is being made to in the logs.

when HTTP_REQUEST { 
  
    log local0. "[IP::client_addr]:[TCP::client_port]: new request on [TCP::local_port] to [HTTP::host][HTTP::uri]" 
  
    if { ! ([string tolower [HTTP::uri]] starts_with "/livenation/") } { 
  
       log local0. "[IP::client_addr]:[TCP::client_port]: redirecting https://vipnation.com/livenation/php/login.php" 
       HTTP::redirect "https://vipnation.com/livenation/php/login.php" 
    } 
 }

Aaron

Hoolio,

Thanks for your response. I did apply the irule that you posted and I can see in the log that the redirection is not working when we go to VIP Nation directly.

Jun 11 14:23:42 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:26719: new request on 80 to VIP Nation

Not exactly sure why it wouldn’t work in the above scenario. Looks like /php/eventslist.php in the end is the culprit because if i go to VIP Nation it redirects properly.

NOTE: redirection works fine for all the following requests though

Jun 11 14:33:36 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28193: new request on 80 to www.vipnation.com/

Jun 11 14:33:36 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28193: redirecting VIP Nation

n/php/login.php

*************

Jun 11 14:33:49 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28221: new request on 80 to 216.23.166.46/

Jun 11 14:33:49 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28221: redirecting VIP Nation

n/php/login.php

*************

Jun 11 14:33:59 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28235: new request on 443 to vipnation.com/

Jun 11 14:33:59 tmm tmm[1510]: Rule vipnation_irule : 216.23.160.47:28235: redirecting VIP Nation

n/php/login.php

*************

Also, to answer your question I am not using two different irules on the vips. There is only one vip but listening on both ports (80 & 443)

Any ideas on why it wouldn’t redirect VIP Nation to https://…

Thank you,

Ram Tangella

Hi Ram -

It looks to me like you are specifically excluding that URL in the condition for the redirect action:

if { ! ([string tolower [HTTP::uri]] starts_with "/livenation/") } {  
       HTTP::redirect "https://vipnation.com/livenation/php/login.php"  
     }

Let’s try a more complete description of when you need to redirect, but I’ll take a guess that you want to redirect all requests for the domain name only to the login page?

If so, try this instead:

when HTTP_REQUEST { 
 if { [HTTP::uri] equals "/") } { 
     HTTP::redirect "https://vipnation.com/livenation/php/login.php" 
   } 
 }

If that’s not it, post back with a list of what needs to be redirected & what doesn’t & we can try to help further.

HTH

/d

Deb,

Thanks for your response!! I did the following irule but again VIP Nation will not redirect to VIP Nation

when HTTP_REQUEST {

if { [HTTP::uri] equals “/”) } {

HTTP::redirect “VIP Nation”

}

}

Redirection works when I go to

http://216.23.166.46

https://216.23.166.46

Doesn’t work only when I go to VIP Nation

Customer wants all the above that already works plus the one that doesn’t get redirected to be working. So we are very close but this is just driving everyone nuts! so far! :slight_smile:

So I am clueless at this point. Thank you all for looking into this with me. I really appreciate all your help.

Thank you,

Ram

If you want to redirect requests to http://vipnation.com/ and https://vipnation.com/ and VIP Nation to the login page you can use Deb’s last example and add a check if the port is 80 and the requested URI is /livenation/php/eventslist.php. If you don’t care whether the port is 80 and always want to redirect /livenation/php/eventslist.php to the login page, then remove ‘([TCP::local_port]==80 and’ from the ‘if’ statement.

when HTTP_REQUEST {  
    if { [HTTP::uri] equals "/" or ([TCP::local_port]==80 and [HTTP::uri] eq "/livenation/php/eventslist.php"} {  
       HTTP::redirect "https://vipnation.com/livenation/php/login.php"  
    } 
 }

Aaron

I’m guessing he wants to redirect all non-SSL traffic to the login page over SSL, AND all paths that aren’t in /livenation/ to the login page (so, only requests to https://…/livenation/* would be allowed through).

when HTTP_REQUEST { 
   if { (! ([string tolower [HTTP::uri]] starts_with "/livenation/")) or ([TCP::local_port]==80) } { 
     HTTP::redirect "https://vipnation.com/livenation/php/login.php" 
   } 
 }

Is that what you’re looking for?

how can i redirect client request for only login page,

i want redirect http request for “login.php” to https after the login page i want keep client on http

can i do with irule or do i need something on serverside?

zafer