Forum Discussion

WillC_97839's avatar
WillC_97839
Icon for Nimbostratus rankNimbostratus
Nov 18, 2009

Different pool, but need to pass the query string along

Hi there.

 

 

I tried doing a search and I found some stuff that kinda helps, but I'm not quite getting the results that I want.

 

 

I have a site, www.widgets.com

 

 

When someone visits the site, and goes to a particular URL (www.widgets.com/widget-search/) I want to use a different pool and also pass the query string that they are search for. That part I got.

 

 

Here's the part I need help with:

 

 

1. The search url (/widget-search/) doesn't match 1-to-1 with the other pool. The other pool uses /search/virtualsearch?q=myquery

 

 

So, in plan english, if I do a search for "brown" directly off the page they have, it'll return something like:

 

 

http://widgets.search.com/search/widgetsearch?q=brown&category=big&section= (etc etc)

 

 

I am able to pull the query and save that, but how do I send that to the pool, along with their particular search path (/search/virtualsearch?q=xxx) ?

 

 

2. I'd like to do is obfuscate it so when people search on www.widgets.com, it comes back like:

 

 

www.widgets.com/widget-search/?q=brown&category=big&section= (etc etc)

 

 

Assuming that I'm able to pass the correct path and query to the other pool, will 2 automatically take place?

 

 

Thanks

 

4 Replies

  • As a side note, I know I can do a HTTP::redirect http://widgets.search.com/search/virtualsearch?myQUERY but then the URL come back as widgets.search.com, not widgets.com

     

     

    Thanks
  • Do you want to preserve the entire query string or just one parameter? Do you need to rewrite the Host header value to widgets.search.com?

    Here is an example which shows a few options. Note that you can "hide" the rewriting by not sending an HTTP redirect. The client won't see the change, assuming the web app does not use the rewritten URI in response headers or content it sends to the client.

     
     when CLIENT_ACCEPTED { 
      
         Save the VIPs default pool name 
        set default_pool [LB::server pool] 
     } 
     when HTTP_REQUEST { 
      
         Check requested URI 
        switch -glob [HTTP::uri] { 
      
           "/widget-search/*" { 
      
               Request needs to go to second pool 
      pool widget_pool 
      
       Rewrite URI to /search/virtualsearch?q= with the original  
         value for the q parameter preserved 
      HTTP::uri "/search/virtualsearch?q=[URI::query [HTTP::uri] q] 
      
       Or... 
      
       Rewrite the URI to /search/virtualsearch with the original query string 
      HTTP::uri "/search/virtualsearch?[HTTP::query] 
      
       Rewrite the Host header to widgets.search.com 
      HTTP::header replace Host "widgets.search.com" 
           } 
           default { 
      
               Use the VIPs default pool 
      pool $default_pool 
           } 
        } 
     } 
     

    Aaron
  • I need the whole string preserved and passed along to the alt. pool. I just need the URL bar to look like the originating host (www.widgets.com, not search.widgets.com). All the links provided by the remote search engine will point back to my site, and not theirs.

     

     

     

    Thanks
  • So you can remove this section of the above example then:

     
        Rewrite URI to /search/virtualsearch?q= with the original   
          value for the q parameter preserved  
       HTTP::uri "/search/virtualsearch?q=[URI::query [HTTP::uri] q]  
        
        Or...  
      
     

    The remaining parts should work as you've described. If you run into any issues, try adding logging to the iRule and check the /var/log/ltm output to help debug them.

    Aaron