Forum Discussion

Jose_Santiago_O's avatar
Jose_Santiago_O
Icon for Nimbostratus rankNimbostratus
Nov 02, 2005

Redirecting real http users.

Hello,

 

I've just migrated from big-ip 4.5.11 to 9.1. In big-ip 4.5 We had a rule to redirect real-server requests (port 8080) from the original URI to URI+?usehostname, since this is the valid syntax to have the real servers behind a NAT or LB.

 

 

This is the rule in 4.5:

 

 

rule real_http {

 

if (not (http_uri ends_with "hostname")) {

 

redirect to "http://%h:8080/%u?usehostname"

 

}

 

else {

 

use pool pool_real_8080

 

}

 

}

 

 

I'm trying to do the same with big-ip 9.1, and so far it hasn't worked yet.

 

 

This is the new rule:

 

 

when HTTP_REQUEST {

 

if {[HTTP::uri] ends_with "usehostname"} {

 

pool pool_real_8080

 

}

 

else {

 

[HTTP::redirect "http://[HTTP::host]:8080/[HTTP::uri]?usehostname"]

 

}

 

}

 

 

The rule checks if the URI ends with usehostname, if it does, then I redirect to the pool, if it doesn't, I redirect the user to same host appending the "?usehostname" to the original URI.

 

 

When the request is: http://1.2.3.4:8080/ramgen/file.rm?usehostname >> It works.

 

When the request is: http://1.2.3.4:8080/ramgen/file.rm >> It doesn't work. (?)

 

 

My real servers log the requests with the URI ending in ?usehostname with status code 200 always, but the clients can't see any files.

 

 

Any ideas what should be happening?

 

 

Thanks in Advance.

 

Jose Santiago Oyervides.

 

  • Try taking the HTTP::redirect command out of the brackets. Also, HTTP::uri begins with a slash and you included one so you'll end up with a double slash at the beginning of the uri which is probably not what you were intending.

    when HTTP_REQUEST {
      if {[HTTP::uri] ends_with "usehostname"} {
        pool pool_real_8080
      } else {
        HTTP::redirect "http://[HTTP::host]:8080[HTTP::uri]?usehostname"
      }
    }

    -Joe
  • Thanks guys.

     

    After changing to

     

     

    HTTP::redirect "http://[HTTP::host]:8080[HTTP::uri]?usehostname"

     

     

    It works!

     

     

    Thanks a lot.

     

    Jose Santiago Oyervides.