Forum Discussion

Craig_Freyman_1's avatar
Craig_Freyman_1
Icon for Nimbostratus rankNimbostratus
Nov 07, 2005

Masking URL

So I've got a number of VIP's going into the BIGIP. Each VIP has a URL associated with it. We use these different URLs to manipulate the traffic in different ways before the traffic is sent back to a single Macromedia Breeze server.

 

 

Breeze is configured to only listen to requests for: breeze.domain.com

 

 

I have a few other domains:

 

 

1. nocache.domain.com

 

2. performance.domain.com

 

 

I need both of these domains to be sent back to the breeze server as if they were going to breeze.domain.com - and it would be nice if the user didnt notice any of this.

 

 

Is there a way to send traffic to the Breeze server so it thinks all traffic is going to breeze.domain.com ?

 

 

I've tried using the HTTP::header replace Host breeze.domain.com in an IRule but it isnt really working. Any ideas out there?

25 Replies

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    No, more like this:
    when HTTP_REQUEST {
       HTTP::header replace Host conference2.telept.com
    }
    when HTTP_RESPONSE {
       if {[HTTP::cookie exists BREEZESESSION]} {
          HTTP::cookie name BREEZESESSION domain telept.com
       }
    }

    The other approach would be:
    when HTTP_REQUEST {
       set orig_host [HTTP::host]
       HTTP::header replace Host conference2.telept.com
    }
    when HTTP_RESPONSE {
       if {[HTTP::status] >= 300 and [HTTP::status] < 400 } {
          set location [HTTP::header Location]
          regsub {.*\.telept\.com} $location $orig_host location
          HTTP::header replace Location $location
       }
    }

    Note: I have not personally tested any of this...

    Good luck.
  • Thanks a million for your help. It is pretty close to working now. Can you just explain in laymens terms what this line does?

     

     

    regsub {.*\.telept\.com} $location $orig_host location

     

     

    The cookie appears to be there now, but the URL it redirects to is incorrect. I'm assuming it has something to do with this reg exp. I might need to modify it a bit.

     

     

    Thanks again.

     

  • regsub {.*\.telept\.com} $location $orig_host location

     

     

     

    If I'm interpreting the TCL documentation correctly...

     

     

     

    Replaces every instance of *.telept.com in the variable location with the contents of variable orig_host and saves it back to the location variable

     

     

     

    Here's the doc on regsub:

     

     

    http://tmml.sourceforge.net/doc/tcl/regsub.html
  • Here's the docs for regsub (Click here)

     

     

    regsub ?switches? exp string subSpec ?varName?

     

     

    This command matches the regular expression exp against string, and either copies string to the variable whose name is given by varName or returns string if varName is not present. (Regular expression matching is described in the re_syntax reference page.) If there is a match, then while copying string to varName (or to the result of this command if varName is not present) the portion of string that matched exp is replaced with subSpec. If subSpec contains a ``&'' or ``\0'', then it is replaced in the substitution with the portion of string that matched exp. If subSpec contains a ``\n'', where n is a digit between 1 and 9, then it is replaced in the substitution with the portion of string that matched the n-th parenthesized subexpression of exp. Additional backslashes may be used in subSpec to prevent special interpretation of ``&'' or ``\0'' or ``\n'' or backslash. The use of backslashes in subSpec tends to interact badly with the Tcl parser's use of backslashes, so it's generally safest to enclose subSpec in braces if it includes backslashes.

     

     

    So, this usage does the following:

     

     

    regsub {.*\.telept\.com} $location $orig_host location

     

     

    expression = ".*\.telept\.com"

     

    string = $location

     

    subSpec = $orig_host

     

    varName = location

     

     

    The regular expression is dissected like this

     

     

    . = any character

     

    * = the next 1-n matches of the previous pattern (any character)

     

    \. = the literal "dot" character

     

    telept = the string telept

     

    \. = the literal "dot character

     

    com = the string com

     

     

    So this regular expression will search for 1-n characters followed by a dot followed by "telept" followed by a dot followed by "com"

     

     

    So it will match the beginning of the string up and including ".telept.com"

     

     

    ie. ??????.telept.com

     

     

    It will then replace the first occurrance of that with $orig_host and place it in the location variable.

     

     

    You said that the redirect isn't working. Can you be a bit more specific. Adding some logging with the log command could help you diagnose if the regexp is really the problem.

     

     

    -Joe

     

  • unRuleY_95363's avatar
    unRuleY_95363
    Historic F5 Account
    Oh, my bad. That regular expression should be:
    regsub {http://.*\.telept\.com} $location "http://$orig_host" location
    The previous RE would match the beginning of the location header information including the "http://" and replace it with the original host.