Forum Discussion

2funky_105078's avatar
Aug 09, 2013

Recursive HTTP redirection, why?

Hello,

 

I tried the following irule which had this idea

 

 

if i go to http://www.example.com/, then it should redirect to

 

http://www.example.com/_bla1bla2bla3?/

 

when HTTP_REQUEST {

 

if { [active_members my_pool] > 0 } {

 

if { not ([HTTP::uri] starts_with "/_bla1bla2bla3?")} {

 

HTTP::redirect http://thenest-eur-de.example.com/_bla1bla2bla3?[HTTP::uri]

 

return

 

}

 

} else {

 

HTTP::redirect http://whatever.com

 

return

 

}

 

}

 

 

  1. If I dont use the condition "if { not ([HTTP::uri] starts_with "/_bla1bla2bla3?")}" then i will get recursive HTTP 302 redirections on my browser, strange.....is it normal?? i thoguht that if i use return, then it doesnt come back to the iRule..
  2. do i need to bring all chars to lower case?

thanks for checking it, i am not a super-hero on irules (yet)!

 

 

Giulio

 

4 Replies

  • 1. If I dont use the condition "if { not ([HTTP::uri] starts_with "/_layouts/nestlepages/markethome.aspx?")}" then i will get recursive HTTP 302 redirections, is it correct?yes

    e.g.

    [root@ve10:Active] config  curl -IL http://thenest-eur-de.example.com/something
    HTTP/1.0 302 Found
    Location: http://thenest-eur-de.example.com/_bla1bla2bla3?/something
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    HTTP/1.0 302 Found
    Location: http://thenest-eur-de.example.com/_bla1bla2bla3?/_bla1bla2bla3?/something
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    ...snipped...
    
    HTTP/1.0 302 Found
    Location: http://thenest-eur-de.example.com/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/_bla1bla2bla3?/something
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 0
    
    curl: (47) Maximum (50) redirects followed
    

    2. do i need to bring all chars to lower case?if case is mixed, i think it is better to use string tolower before comparision.
  • Thank you very much for your valuable help!!

     

     

    One last question. After I defined the HTTP redirection, shall i put the pool in the iRule itself or specify it in the LTM GUI?

     

     

    I mean... i could add the line pool after the inner 'if'.....
  • Thank you very much for your valuable help!!

     

     

    One last question. After I defined the HTTP redirection, shall i put the pool in the iRule itself or specify it in the LTM GUI?

     

     

    I mean... i could add the line pool after the inner 'if'.....

     

    .....

     

    HTTP::redirect http://thenest-eur-de.example.com/_bla1bla2bla3?[HTTP::uri]

     

    pool mypool

     

    return

     

    ....

     

     

    does it matter where i configure the pool? in the GUI or in the iRule?

     

  • HTTP::redirect http://thenest-eur-de.example.com/_bla1bla2bla3?[HTTP::uri]

    pool mypool pool won't be executed because HTTP::redirect already send response to client.

    by the way, if my_pool is already assigned to the virtual server, you can adjust the irule something like this.

    when HTTP_REQUEST {
      if { [active_members [LB::server pool]] > 0 } {
        if { not ([HTTP::uri] starts_with "/_bla1bla2bla3?") } {
          HTTP::redirect "http://thenest-eur-de.example.com/_bla1bla2bla3?[HTTP::uri]"
        }
      } else {
        HTTP::redirect "http://whatever.com"
      }
    }