Forum Discussion

jacob900_39797's avatar
jacob900_39797
Icon for Nimbostratus rankNimbostratus
May 04, 2007

multiple url/uri rewrite w/multiple default statements???

I have a group here at work that wants to accomplish the following translations. It is the same vip but the URI is different for each app. I have a http redirect in place for the http-to-https part. They want to have a simple url that translates into a specific url/uri combination. That is okay too but they also want a "Default" statement put into effect so that for each app any url/uri combination gets redirected to send the user to the right url/uri path.

 

 

Task 1 - convert url into url/uri combination based on what original url is.

 

http://app1.abc.com > https://internal_url.abc.com/app1

 

http://app2.abc.com > https://internal_url.abc.com/app2

 

http://app3.abc.com > https://internal_url.abc.com/app3

 

 

Task 2 for each app to have a deafaul statement so that any url/uri-wildcard cobmination takes them to the right path, ie: url/stuff, url/unknown, etc.

 

http://app1.abc.com/* (anything) > https://internal_url.abc.com/app1

 

http://app2.abc.com/* (anything) > https://internal_url.abc.com/app2

 

http://app3.abc.com/* (anything) > https://internal_url.abc.com/app3

 

 

 

With one app, it's workable but I don't understand how to do multiple url to url/uri redirects and multiple "Defaut" statements. I don't see any examples (so far) that are doing this style exactly. Any samples would be highly appreciated.

 

 

Sample rule for single app - how to do multiple?????

 

when HTTP_REQUEST {

 

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

 

"/app1/*" {

 

pool app1_80

 

}

 

default {

 

HTTP::redirect http://[HTTP::host]/app1/

 

}

 

}

 

}

1 Reply

  • If you define a class with the appropriate app1, app2, app3, etc values, would this meet your needs:

    
    when HTTP_REQUEST {
      set app_path [string tolower [getfield [HTTP::host] "." 0] ]
      if { [matchclass $::defined_apps equals $app_path] } {
        HTTP::redirect "https://internal_url.abc.com/$app_path[HTTP::uri]"
      }
    }

    I haven't tested this, but it should work like this:

    http://app2.abc.com/my_path/internal?userid=citizen_elah

    will be redirected to

    https://internal_url.abc.com/app2/my_path/internal?userid=citizen_elah

    Now if you also want to control pool selection, you could use findclass to extract the pool name associated to the app like so:

    
    when HTTP_REQUEST {
      set app_path [string tolower [getfield [HTTP::host] "." 0] ]
      if { [matchclass $::defined_apps contains $app_path] } {
        HTTP::redirect "https://internal_url.abc.com/$app_path[HTTP::uri]"
      } elseif { [string tolower [HTTP::uri]] starts_with "/$app_path"} {
          pool [findclass $app_path $::defined_apps " "]
      }
    }

    This assumes a class such as:

    "app1 app1-pool"

    "app2 app2-pool"

    "app3 app3-pool"

    Not sure all my ducks are in a row, but perhaps this gives you a springboard to solve your problem.