Forum Discussion

sandy16's avatar
sandy16
Icon for Altostratus rankAltostratus
Nov 13, 2012

stream profile to match customer facing uris

Folks,

 

need help in configuring a stream profile for re-writing uris for a cutomer facing requirement. I have an irule configured on the VIP which basically sends request to different server-pools based on the "/uri". for example the uri "/dev" sends the request to the dev-server-pool, "/qa" goes to the qa-server-pool ...and so on. I see that my requests are hitting the end servers based on the uri, BUT my issue is I am not getting valid content displayed on the webpage. I have no assistance from the developers who are responsible for the end web servers, so have to do all these re-writes from the F5 end. How do i make a "/dev" or qa being added to all the response i recieve from the servers using a stream profile so that all of the content is displayed accurately on the vip.

 

7 Replies

  • Hey Sandev, can you post the current rule so I can make the necessary modifications please?
  • here you go -

     

     

    when HTTP_REQUEST {

     

    log local0. "URI = [HTTP::uri]"

     

    switch -glob [string tolower [HTTP::uri]] {

     

    "/devproxy" {

     

    pool devproxy-pool

     

    return

     

    }

     

    "/qaproxy" {

     

    pool qaproxy-pool

     

    return

     

    }

     

    "/uatproxy" {

     

    pool uatproxy-pool

     

    return

     

    }

     

    default {

     

    HTTP::respond 200 content "Please use /devproxy to go to the dev-dmz-proxies,

     

    /qaproxy to go to the qa-dmz-proxies,

     

    /uatproxy to go to the uat-dmz-proxies" noserver Content-Type "text/html" Connection Close

     

    }

     

    }

     

    }
  • OK, here's my first attempt. They may be a better way but for now I'm assuming the domain name ends with .com so we can match the start of each URI with .com/. If I just used / it will replace every / in the path and break things. Replace .com with whatever you use.

    
    when HTTP_REQUEST {
     STREAM::disable
     log local0. "URI = [HTTP::uri]"
     switch [string tolower [HTTP::uri]] {
      "/devproxy/" {
       pool devproxy-pool
       set environuri /devproxy/
       return
        }
      "/qaproxy/" {
       pool qaproxy-pool
       set environuri /qaproxy/
       return
       }
      "/uatproxy/" {
       pool uatproxy-pool
       set environuri /uatproxy/
       return
       }
      default {
       HTTP::respond 200 content "Please use /devproxy to go to the dev-dmz-proxies,
       /qaproxy to go to the qa-dmz-proxies,
       /uatproxy to go to the uat-dmz-proxies" noserver Content-Type "text/html" Connection Close
    }
    }
    }
    
    when HTTP_RESPONSE {
     switch string $environuri {
      "/devproxy/" {
       STREAM::expression {@.com/@.com/devproxy/@}
       STREAM::enable
       return
        }
      "/qaproxy/" {
       STREAM::expression {@.com/@.com/qaproxy/@}
       STREAM::enable
       return
       }
      "/uatproxy/" {
       STREAM::expression {@.com/@.com/uatproxy/@}
       STREAM::enable
       return
       }
     }
    }
    
  • Hi Steve, in the irule editor it says "Response is not a well formed XML", what are we missing?
  • Does the error message reference a specific part of the code at all? If not can you try configuring it as two rules, once for the REQUEST, one for the RESPONSE.

     

     

    Also, you might want to try adding { after content and } before noserver.
  • The irule editor does not throw an error on a particular line number. I tried to add them separately, it still gives "not well formed xml" on the response one.

     

    I didn`t get the part "Also, you might want to try adding { after content and } before noserver.", where should i add this?
  • Like so;

    
      default {
       HTTP::respond 200 content { "Please use /devproxy to go to the dev-dmz-proxies,
       /qaproxy to go to the qa-dmz-proxies,
       /uatproxy to go to the uat-dmz-proxies" } noserver Content-Type "text/html" Connection Close