Forum Discussion
irule redirect without changing host on client
hi,
I have an application which is access via our F5 loadbalancer. Lets say the url is http://xyz.com/my/application/. The users accessing the url must be redirected to http://xyz.com/application/ i have been busy figuring out how to accomplish this, by using a http::redirect it works fine but i don't want the url xyz.com to be changed in the clients webbrowser to the actual pool ip address. When i'm using the string range function to strip some characters off it works almost fine except i'm missing some page layout/stylesheets as the application expects them in the /application folder instead of /my/application folder because the clients browser url remains the same.
irule which is partially working but no stylesheet:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
"/my/application/_" {
pool application_pool
HTTP::uri [string range [HTTP::uri] 3 end ]
}
"/test/other/_" {
pool test_pool
HTTP::uri [string range [HTTP::uri] 5 end ]
}
default {
pool other_pool
}
}
}
irule which works but changes the url in the clients webbrowser:
when HTTP_REQUEST {
switch [string tolower [HTTP::uri]] {
"/my/application/_" {
HTTP::redirect "http://10.1.1.12[string range [HTTP::uri] 3 end]" }
"/test/other/_" {
HTTP::redirect "http://10.1.1.13[string range [HTTP::uri] 5 end]" }
default {
pool other_pool
}
}
}
(how) can this be done?
3 Replies
- Kevin_Stewart
Employee
Hoping you can clarify something. Let's take the two examples:
when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/my/application/_" { pool application_pool HTTP::uri [string range [HTTP::uri] 3 end ] } "/test/other/_" { pool test_pool HTTP::uri [string range [HTTP::uri] 5 end ] } default { pool other_pool } } }In this iRule, if the user makes a request for "/my/application/_", you change the URI inline to "/application/_" and then send the request to the application_pool. Any request to say, "/application/layout.css" would go to the other_pool.
when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/my/application/_" { HTTP::redirect "http://10.1.1.12[string range [HTTP::uri] 3 end]" } "/test/other/_" { HTTP::redirect "http://10.1.1.13[string range [HTTP::uri] 5 end]" } default { pool other_pool } } }In this iRule, if the user makes a request to "/my/application/_", he is immediately redirected to "http://10.1.1.12/application/_", which is caught by the default condition and sent to the other_pool. Any request to say, "/application/layout.css" would go to the other_pool.
So a few questions:
-
Do the same servers exist in the application_pool and other_pool?
-
What would a CSS URI look like?
-
- Kevin_Stewart
Employee
Just guessing here, but you're CSS is likely being referenced from the client directly as "/application/something.css", in which case I think your first iRule can use a minor tweak:
when HTTP_REQUEST { switch [string tolower [HTTP::uri]] { "/my/application/*" { pool application_pool HTTP::uri [string range [HTTP::uri] 3 end ] } "/application/* { pool application_pool } "/test/other/*" { pool test_pool HTTP::uri [string range [HTTP::uri] 5 end ] } default { pool other_pool } } } - bk1_144234
Nimbostratus
Hi Kevin, Meanwhile i also tried it the way you suggested and this is indeed the way to go, i made it more complex then it should be ;). thanks for your help!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com