Redirect based on virtual directory name in IIS

Hi,

I am new to irules and need this help.

VIP: 192.168.100.100

Webpool1 - 4 Nodes, each containing ideal set of web applications.

Now apps are like http://192.168.100.100/app1, http://192.168.100.100/app2

I have requirement that the customer does not want to type http://servername/app1 instead he wants to type http://app1 to access app1.

We have around 50+ apps and all apps need to be accessed as http://appname.

TIA

Regards,

Ravi

Hi,

I have already got the DNS entries done in the local name servers. So now app1 resolves to 192.168.100.100. Now its the irule part which i need help.

TIA,

Regards,

Ravi

Thanks, i will test this and let you know.

BTW, in the irule, where are we checking for http://app1 and then redirecting to http://192.168.100.100/app1

TIA,

Regards,

Ravi

Hi,

This doesn’t work and i get a bad request message. Can we log some messages in var/log/ltm to get some details.

TIA,

Regards,

Ravi

You certainly can. You can insert log commands wherever you’d like in the rule to log information. Log commands look like:

log local0. "Info to log here.  E.G. current host is [HTTP::host]"

Colin

Hi,

Thanks !! I tried the below code and it worked !!

when HTTP_REQUEST {

if {[HTTP::host] ne “192.168.100.100”} {

HTTP::uri /[HTTP::host]

HTTP::header replace HOST “192.168.100.100”}

}

Now, I have some room for enhancement here. If the hostname is different from the actual virtual directory… For eg. user will type http://application and the redirection should happen to http://192.168.100.100/app1

I think we need to use arrays which map the URL name with the actual application name. Need views on this.

TIA,

Regards,

Ravi

You could create a DataGroup called AppDir and then use

HTTP::uri /[findclass [HTTP::host] $::AppDir " "]
HTTP::header replace HOST "192.168.100.100"

AppDir would be of type ‘string’ and contain entries like

application1 app1
application2 app2
application3 app3
...

This would replace http://application1/ with http://192.168.100.10/app1

Thanks a bunch !! This works perfect. I am testing it and will come back if i have any queries.

Regards,

Ravi