For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Forum Discussion

Peter_125758's avatar
Peter_125758
Icon for Nimbostratus rankNimbostratus
Jun 25, 2014

Forward to specific pool and remove URL's path

I am really stuck and can't figure what's wrong and need help. BTW, I am a newbie.

 

Rewrite to URL and strip part of the URI

 

Example 1) URL https://www.xyz.com/index1.html default POOL1 2) URL https://www.xyz.com/ping so when someone enter 2, it would forward to POOL2 and remove the "/ping path" to just only https://www.xyz.com

 

when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path [string range [HTTP::path] 0 3] pool POOL2 } else { pool POOL1 } }

 

9 Replies

  • when HTTP_REQUEST { 
      if { [HTTP::uri] starts_with "/ping" } { 
        HTTP::path "/"
        pool POOL2
      } else { 
        pool POOL1
      } 
    }
    
    • Peter_125758's avatar
      Peter_125758
      Icon for Nimbostratus rankNimbostratus
      Thank you very much. It actually forward to the pool2 when the initial input has a /ping path. However, the /ping path is still not removed permanently. So, how do you remove the path "/ping" permanently?
  • The /ping path is removed from the traffic passing to the pool you just don't see that in the browser. If you want it in the browser then you have to use HTTP::redirect "/". However then your request will go to POOL1 everytime as you will make a new request with "/".

     

  • Hi Kevin,

     

    Thank you very much for your prompt reply. I did exactly as you suggested, and got the POOL2 page, but when I start browsing the page, I got 404 error. Guess, I need to do more researches.

     

    Thank you very much, -Peter

     

  • Ahh so /ping is not a one off page. You want to browse a site from that pool, ok then we need to adjust your iRule.

    when HTTP_REQUEST { 
      if { [HTTP::uri] starts_with "/ping" } { 
        HTTP::path "/[string range 6 end]"
        pool POOL2
      } else { 
        pool POOL1
      } 
    }
    
  • Thank you very much, I still got a 404 error when browse the pool. I mean once the forward to POOL2, user should be able to browse everything in POOL2 per your advice. I wonder if the version 11.3 has a bug w/ iRule.

     

    when HTTP_REQUEST { if { [HTTP::uri] starts_with "/ping" } { HTTP::path "/[string range 0 6 end]" pool POOL2 } else { pool POOL1 } }

     

  • I still got a 404 error when browse the pool. I mean once the forward to POOL2, user should be able to browse everything in POOL2 per your advice. I wonder if the version 11.3 has a bug w/ iRule.

     

    i do not think it is a bug. i think it is about how uri is organized.

     

    have you ever used http analyzer tool such as httpfox? it may be helpful.

     

    HttpFox

     

    https://addons.mozilla.org/en-US/firefox/addon/httpfox/

     

  • The issue here is we do not have enough detail on what you want to achieve. When you make a request using /ping, are you expecting all the subsequent requests to now come from pool2? If so you need to add persistence in addition to the iRule. Start with adding source address persistence and see if that resolves your issue.

    Here is a logging iRule you can use to track what is going on. Paste the logs to gist.github.com and drop a link here.

    when CLIENT_CONNECTED { 
      set cid [clock clicks]
      log local0. "\[$cid\] Client Connected XXXX"
    }
    when HTTP_REQUEST {
      set rid [clock clicks]
      log local0. "\[$rid\] HTTP Request for [HTTP::uri] XXXX"
    }
    

    From the command line your BIGIP then use the following commands to get your logs

    tail -f /var/log/ltm | grep XXXX