Forum Discussion
Redirect the traffic based on uri
Hi I have to create a i-rule for a request mentioned below. The users will be using the same URL, but different URIs and should be redirected to different ports and URIs on the servers. I have tried to write the code and logic. Can someone please check and confirm it the logic and syntax is correct ?
when HTTP_REQUEST { if { [HTTP::uri] contains "/abc/efg/Contract" } { node 172.27.117.68 89 } elseif { [HTTP::uri] contains "/xyz_QuotationService" } { node 172.27.117.68 99 } default { pool pool_default } }
Your iRule is generally OK, it should look like this (alternatively you could use switch statement):
Code
when HTTP_REQUEST { if { [HTTP::uri] contains "/abc/efg/Contract" } { node 172.27.117.68 89 }
elseif { [HTTP::uri] contains "/xyz_QuotationService" } { node 172.27.117.68 99 }
else { pool pool_default }
}
- Samir_Jha_52506
Noctilucent
Try below iRule. Hope it will fit in your box.
when HTTP_REQUEST { if { [HTTP::uri] contains "/abc/efg/Contract" } { HTTP::redirect "http://172.27.117.69:89/acldata.asmx"} elseif { [HTTP::uri] contains "/xyz_QuotationService" } { HTTP::redirect "http://172.27.117.69:89/ACLData.asmx" } else { pool pool_default } }
Redirect will not help here. Middleware hosts need to do further work.
- AshuA_246482
Nimbostratus
Hi F5_Rock,
Thanks for your response.
For a external user doesn't http redirect will throw 30X to user request and user will be pointed to internal url in his browser then it will become unavailable for a external user ? because middleware is internal and not exposed to internet.
- AshuA_246482
Nimbostratus
Hi Only1masterblaster,
What kind of further work is expected? can you please give me some idea ?
Thanks
- Andy_McGrath
Cumulonimbus
Think this is what you want to do, match a URI set change the URI before selecting a node to forward on to.
Technically you do not need the final default pool so I have left it out, will select this by default if the iRule returns without making a pool or node selection.
when HTTP_REQUEST { if {[HTTP::uri] contains "/abc/efg/Contract" } { HTTP::uri "/acldata.asmx" node 172.27.117.68 89 } elseif {[HTTP::uri] contains "/xyz_QuotationService"} { HTTP::uri “/ACLData.asmx" node 172.27.117.68 99 } }
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