Forum Discussion
iRule to redirect based on context
Hi,
I would like to redirect as the following and the user must see the initial address on their browser; not the redirected IPaddress.
https://abc.website1.com/123 to and https://abc.website1.com/456 to and https://abc.website1.com/789 to and so on
Is this feasible? Please provide me with iRule example. I am very new to F5. Any help is much appreciated.
3 Replies
- Kevin_Stewart
Employee
The easier option may be to put each of these internal IP addresses into separate pools and then do something like this:
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/123*" { pool pool_123 } "/456*" { pool pool_456 } "/789*" { pool pool_789 } } }Where "pool_123" is the pool that contains the server with ipaddress1, etc. You're not technically redirecting but rather proxying the traffic. The client will only see the URL that they entered.
- Rias_212360
Nimbostratus
Thanks Kevin,
We tried what you suggested. It looks like the irule proxies the traffic to "/123" on the destination URL. But I do not have the "/123". I expect it to directly proxy to ""
Is there any special setting available to achieve this? Thanks for your help.
- Kevin_Stewart
Employee
So there's no URI behind that address?
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/123*" { HTTP::uri "/" pool pool_123 } "/456*" { HTTP::uri "/" pool pool_456 } "/789*" { HTTP::uri "/" pool pool_789 } } }This modification will replace the incoming URI with an empty one. Of course at this point you have to be careful about how the application works. If a browser requests http://external.domain.com/123, and you send that to the first pool and change the URI to "/" (from /123), how does the web server respond? Does it respond with HTML content that points back to a specific URI pattern (ex. /123/images/mycat.png)? If the HTML document that you get back contains document objects that the browser is expected to go get (images, styles, scripts, etc.), you'll have to take into account how those URIs will be presented to the client.
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