Forum Discussion

Leslie_South_55's avatar
Leslie_South_55
Icon for Nimbostratus rankNimbostratus
Oct 17, 2008

Using LB_FAILED and change the URI w/o 302

I am trying to use the 'when LB_FAILED' to send requests a pool just for apologies. The issue is that the requests coming into the VS have crazy long URI strings like '/ABC/def/g/hij/klmno/' and my sorry server is running a simple HTML page at '/apologies/apologies.htm' I have configured this directory and page to be the default, so I can hit the server directly at 'http://host.domain.com/' and get the correct content. I have tried a few different variations, and can't seem to be able to change the URI after 'when LB_FAILED' before the request goes to the apologies pool.

Rev 1, I added some logging to see what was being passed

 
 when LB_FAILED { 
 log local0. "URI is [HTTP::uri]" 
 log local0. "$poolname has [active_members [LB::server pool]] members" 
 log local0. "URI is [HTTP::uri]" 
 pool pool_apologies_http 
 log local0. "Directed to pool [LB::server pool]" 
   } 
 

Rev 2, tied the HTTP::uri command

 
 when LB_FAILED { 
 log local0. "URI is [HTTP::uri]" 
 log local0. "$poolname has [active_members [LB::server pool]] members" 
  HTTP::uri "/" 
 log local0. "URI is [HTTP::uri]" 
 pool pool_apologies_http 
 log local0. "Directed to pool [LB::server pool]" 
   } 
 

Can I do this with the 'when LB_FAILED' command, or does it have to be HTTP_REQUEST??

Thanks,

-L
  • It looks like there are two instances of the directory in the path:

     

     

    /Library/controller/e/web/Portal/en/maintenance_files/maintenance_files/main.css

     

     

    Aaron
  • OK, found the issue. I modified the maintenance.htm file so that ever reference to 'maintenance_files/main.css' or other objects now looks like '/maintenance_files/main.css' looks like without the preceeding / the path was relative. After making this change, the page appears correctly. I will post the final rule soon, after I do some more testing.

     

     

    Thanks Aaron for your diligent efforts.

     

     

    -L
  • Leslie,

     

     

    I'm also having same requirement. I'm did not understand what you did to the page to fix the issue?

     

     

    Could you explain?

     

     

    Regards,

     

    Sridhar
  • You can create a /maintenance.html page in the application, add any content the maintenance.html page references under a /maintenance/ directory, add the maintenance server(s) to a pool named pool_apologies_http and then use this iRule:

       when LB_FAILED {   
          
          log local0. "[IP::client_addr]:[TCP::client_port]: Request for [HTTP::uri] from Referer '[HTTP::header Referer]' to pool failed, [LB::server pool]"   
          
           Check if this request was not generated from the maintenance page using the HTTP referer header   
          if {not ([HTTP::path] contains "/maintenance_files/")}{   
          
             log local0. "[IP::client_addr]:[TCP::client_port]: Referer wasn't the maintenance page.  Rewriting URI to maintenance page."   
             HTTP::uri "/maintenance.htm"
          }  
          
           Send request to the apologies pool   
          LB::reselect pool pool_apologies_http   
          log local0. "[IP::client_addr]:[TCP::client_port]: Reselecting member from the apologies pool"   
       }
    

    Aaron