Forum Discussion
iRule for directing a uri to a port
I am fairly new to iRules so forgive me if this is a simple or dumb question.
Is it possible to configure an irule such that a HTTP request to a web URL can be identified by the information following the host name.
For example the hostname being website.com
Would it be possible using an iRule to perform a sort of case statement
website.com/part1 ---> server:80
website.com/part2 ---> server:81
website.com/part3 ---> server:82
Looking through some other iRule requests it seems the following could be close.
when HTTP_REQUEST {
if { [HTTP::uri] equals "/part1" } {
HTTP::redirect ":80"
}
else { [HTTP::uri] equals "/part2" } {
HTTP::redirect ":81"
}
}
Thank you
- Faruk_AYDIN
Nimbostratus
Hi Guy,
if you want to only redirect the users use that :when HTTP_REQUEST { switch -glog [string tolower [HTTP::uri]] { "/part1" { HTTP::redirect "http://website.com:80/part1" } "/part2" { HTTP::redirect "http://website.com:81/part2" } "/part3" { HTTP::redirect "http://website.com:82/part3" } } }
But, in my opinion, you are using different ports on your servers for different applications, and you don't want your users to know those ports and to write on their browser address bars. If so, use this irule :
when HTTP_REQUEST { let's say your server ip is 10.10.10.10 set server "10.10.10.10" switch -glog [string tolower [HTTP::uri]] { "/part1" { node $server 80 } "/part2" { node $server 81 } "/part3" { node $server 82 } } }
Hope it helps
Please mark it as answer if it is fine for you.
Best wishes
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