Forum Discussion

Steve_130921's avatar
Steve_130921
Icon for Nimbostratus rankNimbostratus
Nov 15, 2013

Changing the URL from the original VIP address to the Node's address

My customer is asking me if it is possible to change the URL that is presented on the Web page to reflect the actual real server name instead of the VIP DNS name. For troubleshooting purposes.

 

iRules, as I understand them, can make load balancing decisions on where to load balance but I don't know if it can make the LB decision and then modify the name on the URL when the page is displayed.

 

Any Advice?

 

3 Replies

  • If you're referring to the URL displayed in the browser's address bar, then understand that this is actually more of a DNS issue than anything else. The contents of that bar are a function of the browser itself and are generally not influenced by the HTTP traffic. For example, in order to change the address bar, you must issue a physical redirect. That redirect will cause the browser to have to look up this new URL and then go there. So in your case, the internal name would have to be both resolvable and accessible. Assuming this is not what you want, here is an alternative:

     

    In the HTTP response event, take the chosen internal server (name or IP) and insert it into the HTML payload. You could, for example, add it to the bottom of the page, or as a hidden value inside the HTML source.

     

  • It's pretty straight forward. Add an empty STREAM profile to your VIP and this iRule:

    when HTTP_REQUEST {
        STREAM::disable
        HTTP::header remove "Accept-Encoding"
    }
    when HTTP_RESPONSE {
        if { [HTTP::header value Content-Type] contains "text" } {
            STREAM::expression "@[/body]@[LB::server addr][/body]@"
            STREAM::enable
        }
    }
    

    The STREAM profile here will add the chosen server's IP address just before the end body tag of the document. You could extend this in a few ways:

    1. The additional information is more or less pure HTML, so you could through it all into a hidden object or HTML comment.

    2. You could do a reverse lookup of that IP to get the server name, and then do the above:

      when RULE_INIT  {
          set static::dns_server 10.80.0.200
      }
      when HTTP_REQUEST {
          STREAM::disable
          HTTP::header remove "Accept-Encoding"
      }
      when HTTP_RESPONSE {
          if { [HTTP::header value Content-Type] contains "text" } {
              set servername [RESOLV::lookup @$static::dns_server -ptr [LB::server addr]]
              STREAM::expression "@[/body]@$servername[/body]@"
              STREAM::enable
          }
      }
      
  • Thanks Kevin. This might actually be fun to set up. But since I'm only recently getting it online, it will be a while before I'm able to play with it.

     

    Thank you for the added details.