Forum Discussion

kng_107168's avatar
kng_107168
Icon for Nimbostratus rankNimbostratus
Mar 02, 2011

unable to redirect to a different page on another pool

This is what I have but the client browser doesn't seems to like the redirection.

 

 

when HTTP_REQUEST {

 

if { [active_members poolA] < 1 } {

 

use pool poolB

 

HTTP::redirect "/splash.html"

 

}

 

}

 

 

Essentially I want the HTTP::host to be the same. I don't really care of the uri, whether the user sees the splash.html or not.

 

 

Can anyone point out what I'm doing wrong please?

 

 

Thanks in advance.

 

 

Ken

 

20 Replies

  • Yep - I was basically asking whether LTM was terminating the SSL so it could see clear text.

     

     

    I'm wondering if the issue is because we're using active_members from within HTTP_REQUEST. HTTP_REQUEST probably isn't being triggered if the pool members are down.

     

     

    I'm gonna do some research quick.
  • I think Chris' original example should work if the splash.html page doesn't reference any other objects on the same fully qualified domain name. HTTP_REQUEST will be triggered regardless of whether there is a pool on the virtual server or whether the pool is up.

    You could also use the VS default pool instead of hardcoding poolA.

    
    when CLIENT_ACCEPTED {
    
        Save the name of the VS default pool
       set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
    
       log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]"
       if { [active_members $default_pool] < 1 } {
          log local0. "[IP::client_addr]:[TCP::client_port]: No members for $default_pool. Rewriting URI to /splash.html and using poolB"
          pool poolB
          HTTP::uri /splash.html
       } 
    }
    

    If that doesn't work, check the /var/log/ltm debug to see what's happening. I'd guess the issue is with content referenced in /splash.html getting rewritten to /splash.html. If that's the case, then you could move /splash.html to a new unique subdirectory and use something like this:

    
    when CLIENT_ACCEPTED {
    
        Save the name of the VS default pool
       set default_pool [LB::server pool]
    }
    when HTTP_REQUEST {
    
       log local0. "[IP::client_addr]:[TCP::client_port]: [HTTP::method] to [HTTP::host][HTTP::uri]"
       if { [active_members $default_pool] < 1 || [HTTP::uri] starts_with "/maintenance/"} {
          log local0. "[IP::client_addr]:[TCP::client_port]: No members for $default_pool. Rewriting URI to /maintenance/splash.html and using poolB"
          pool poolB
          HTTP::uri "/maintenance/splash.html"
       } 
    }
    

    This latter example would work assuming any objects splash.html references are relative to the current path.

    Aaron
  • Yeah, not sure what I was thinking.

    Let's try this

    
    when CLIENT_ACCEPTED {
         if { [active_members poolA] < 1 } {
                pool poolB
                set maint 1 }
        else { set maint 0 }
     }
    when HTTP_REQUEST { 
       if { $maint eq 1 } {
            HTTP::uri /splash.html } 
          } 
    
  • Hah - Thanks Aaron...I assumed HTTP_REQUEST wouldn't trigger if LB_FAILED was triggered.
  • If you have an HTTP profile on a VS, TMM will:

     

     

    accept the connection (CLIENT_ACCEPTED)

     

    try to parse the HTTP headers (HTTP_REQUEST)

     

    select a pool member assuming there is a pool being used (LB_SELECTED)

     

    on a load balancing failure trigger LB_FAILED

     

     

    If a preceding event fails then subsequent ones wouldn't be triggered.

     

     

    Aaron
  • I tried Chris' suggestion but not working.

     

     

    Hoolio: I tried yours too but it's not working either. Here are the log entries.

     

     

    Mar 3 13:22:42 local/tmm info tmm[4064]: Rule test_redirect_irule : 1.1.1.1:54562: GET to www.abc.com/login.jsp

     

    Mar 3 13:22:42 local/tmm info tmm[4064]: Rule test_redirect_irule : 1.1.1.1:54562: No members for poolA. Rewriting URI to /maintenance/splash.html and using poolB

     

     

    That's all.
  • When you say it doesn't work, what does the client actually receive when the URI is rewritten to /maintenance/splash.html? Have you changed the location of the splash.html page to move it to the /maintenance/ directory?

     

     

    Aaron
  • Yes, I have tried it putting the splash file into the maintenance directory but still not working. I think the client browser just get some sort of network reset. It never received any content of the splash page. And the splash page is just very simple html code, like hello world.
  • Do you see any errors in /var/log/ltm? If not, can you run a tcpdump on LTM to see if the request is making it there?

     

     

    Aaron