Forum Discussion
Redirect traffic to root directory on server pool
Hi there,
Wondering if anyone can help. Will this iRule work. I want to be able to look at URL straing for data and send it to specific pool listening on port 81 once it hits this pool to have it look in the root forward. If these are not met send traffic to a different pool.
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/data/" } {
pool IESDWEB_HTTP_81} { "/"
} else {
pool IESDWEB_HTTP
}
}
Regards,
Michael.
6 Replies
- The_Bhattman
Nimbostratus
Hi Michael,
I don't believe this will work if I understand your question properly. Hopefully if I do I understand this properly you want to send traffic to pool IESDWEB_HTTP_81 if the URI starts with /DATA/ string, but then to direct them to URI "/" when you send them to the pool else send them to alternate pool.
You could then rewrite this aswhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri "/" pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }
I choose to use switch statement because in the grander scheme is more efficient then IF-ELSE statements when doing the same comparisons.
I hope this helps
Bhattman - Micka_61352
Nimbostratus
Thank you for you comment.
I have url for example http://test.test.com/data which I want to go to pool IESDWEB_HTTP_81 which is listening on port 81
On the web server there is no data folder but instead a folder structure /:81/Account/LogOn
So I would to have F5 check for string in URL /data/ but essentially redirect this to the http://test.test.com:81/Account/LogOn
Does that make sense - The_Bhattman
Nimbostratus
Hi Michael,
If you have port translation turned on then it's possible you don't need port 81 in the URL itself.
In that case you can write it up as the followingwhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri "/Account/LogOn" pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }
However, incase you don't it could be written in the following mannerNote: I haven't tested this method out before so hopefully it workswhen HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri ":81/Account/LogOn" pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }
Bhattman - Micka_61352
Nimbostratus
Hi Batmann
Thanks for you comments but still have issue. Have some further detail about issue, uri starts with /DATA/ send to specific pool, the request should not be sent to Data folder(as this does not exist) but to redirect them to root folder on IIS folder structure on specific server with pool. If not matching this send to default pool.
Regards, - Micka_61352
Nimbostratus
Hi Bhattmann
Thanks for you comments but still have issue. Have some further detail about issue, uri starts with /DATA/ send to specific pool, the request should not be sent to Data folder(as this does not exist) but to redirect them to root folder on IIS folder structure on specific server with pool. If not matching this send to default pool.
Does this look right?
when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri "/" pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }Or what would be the best way to handle this.
Thanks
- Michael_Yates
Nimbostratus
This iRule will remove the "/data" from your URI, but it will not replace the target document.
So if your URL was:
http://www.website.com/data/default.html
This iRule should mask the "/data" from being sent to the server:
Client Browser should show: http://www.website.com/data/default.html
Request send to the Server will be: http://www.website.com/default.html
If you need to modify the target document then you will want to make adjustments to this iRule.when HTTP_REQUEST { switch -glob [string tolower [HTTP::uri]] { "/data/*" { HTTP::uri [string map {"/data" ""} [string tolower [HTTP::uri]]] pool IESDWEB_HTTP_81 } default { pool IESDWEB_HTTP } } }
Hope this helps, but if it is not let us know what behavior you still need adjusted.
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
