Forum Discussion

Tobias_Neumeyer's avatar
Tobias_Neumeyer
Icon for Nimbostratus rankNimbostratus
Jun 29, 2009

iRule / uri parameter manipulation

Hi,

 

 

Sorry, but I need some help from some experts again.

 

 

I'm trying to write an iRule which modifies a post request to the server.

 

This is the example request.

 

 

https://wss01.sharepoint.mydomain.com/Job%20Requisition%20and%20Management/_layouts/searchresults.aspx?k=eula&u=https%3A%2F%2Fwss01%2Esharepoint%2Emydomain%2Ecom%2FJob%20Requisition%20and%20Management

 

 

What I'm trying to do is to modify the parameter "u=https" to "u=http" only if the uri contains "/searchresults.aspx" before it is send to the server. The Hosts can be diffrent as well.

 

 

Thank you very much advance

 

Tobias

5 Replies

  • Hi Tobias,

    Something like this?

     
     when HTTP_REQUEST { 
      
         Check if path ends with /searchresults.aspx 
        if {[string tolower [HTTP::path]] ends_with "/searchresults.aspx"}{ 
      
            Rewrite URI for u=http:// to u=https:// 
           HTTP::uri [string map -nocase {u=http:// to u=https://} [HTTP::uri] 
      
           log local0. "[IP::client_addr]:[TCP::client_port]: Updated query string to [HTTP::query]" 
        } 
     } 
     

    I'm assuming there won't be any other scenarios where a parameter ends with u and starts with http://. I suppose you could parse the actual value for an actual parameter named "u" using [URI::query [HTTP::uri] u], replace http:// with https:// and then replace the original value with the updated one. But that seems like a log of unnecessary overhead.

    Aaron
  • Hi Aaron,

     

     

    I really appreciate your input. Thanks a lot.

     

     

    If I'm using your iRule I get the following error.

     

     

    01070151:3: Rule [wss_search_rewrite] error:

     

    line 7: [string map list should have an even number of elements] [{u=http:// to u=https://}]

     

     

    Could be that the rule tries to compare http with u or something like this?

     

     

    Any idea what could be wrong?

     

     

    Thanks a lot!

     

     

    Tobias

     

  • Sorry, bad copying and pasting on my part. I was also missing a closing square brace after HTTP::uri. You can remove the "to" in the middle. And actually, if you're on a version lower than 9.4.7, you should replace the curly braces with double quotes to avoid a bug (SOL7988 - Click here).

     
      when HTTP_REQUEST {  
      
          Check if path ends with /searchresults.aspx  
         if {[string tolower [HTTP::path]] ends_with "/searchresults.aspx"}{  
      
             Rewrite URI for u=http:// to u=https://  
            HTTP::uri [string map -nocase "u=http:// u=https://" [HTTP::uri]] 
      
            log local0. "[IP::client_addr]:[TCP::client_port]: Updated query string to [HTTP::query]"  
         }  
      } 
     

    Aaron
  • Is the update actually being made in the request to the server? Maybe it's a problem with caching of the HTTP:: commands. I thought using HTTP::query would have shown the update. Can you try logging in a second HTTP_REQUEST event?

     
       when HTTP_REQUEST {   
      
           Check if path ends with /searchresults.aspx 
          if {[string tolower [HTTP::path]] ends_with "/searchresults.aspx"}{   
      
              Rewrite URI for u=https:// to u=http:// 
             HTTP::uri [string map -nocase "u=https:// u=http://" [HTTP::uri]]  
      
             log local0. "[IP::client_addr]:[TCP::client_port]: Updated query string to [HTTP::query]" 
          }   
       } 
       when HTTP_REQUEST priority 501 { 
             log local0. "[IP::client_addr]:[TCP::client_port]: 501 Updated query string to [HTTP::query]" 
       } 
     

    Aaron
  • Is the change actually being made to the requested URI? If you check the server logs or run tcpdump on the server VLAN, do you see the URI being rewritten?

     

     

    Aaron