Forum Discussion
Required help for irule on single url
Virutal server ( IP 1.1.1.1--my http class will be http://xyz.com) should forward all the request to (2.2.2.2-http://abc.com) ,( 2.2.2.3-http://def.com) and (2.2.2.4 - http://ghi.com) and from outside it should work like below 3 url http://xyz.com/abc, http://xyz.com/def, http://xyz.com/ghi
4 Replies
- Mohamed_Saalih_
Nimbostratus
Virutal server ( IP 1.1.1.1--my http class will be http://xyz.com) should forward all the request to (2.2.2.2-http://abc.com) ,( 2.2.2.3-http://def.com) and (2.2.2.4 - http://ghi.com) and from outside it should work like below 3 url http://xyz.com/abc, http://xyz.com/def, http://xyz.com/ghi - IheartF5_45022
Nacreous
Just one approach - I'd create 3 pools;-
pl_xyz_http members {2.2.2.2:80 2.2.2.3:80} pl_def_http members {2.2.2.3:80 2.2.2.4:80} pl_ghi_http members {2.2.2.4:80}Then on your VIP apply round-robin and oneconnect profile and the following iRule;-
when HTTP_REQUEST { set path_seg1 [lindex [split [HTTP::path] / ] 1 ] switch $path_seg1 { "xyz" - "abc" - "ghi" { Rewrite Host header HTTP::header replace Host "${path_seg1}.com" Rewrite path HTTP::path "/" pool "pl_{$path_seg1}_http" } default { Will be sent to default pool attached to virtual } } }There are obviously many ways to approach this though
- Mohamed_Saalih_
Nimbostratus
Dear i heartF5 i have modified the things can you please again check and revert back to me
Thanks Mohamed Saalih
- IheartF5_45022
Nacreous
I'd probably leave it the same except for the pool definitions
pl_abc_http members {2.2.2.2:80} pl_def_http members {2.2.2.3:80} pl_ghi_http members {2.2.2.4:80}Slight tweak to iRule to show you some other things you might want to do;-
when HTTP_REQUEST { set path_seg1 [lindex [split [HTTP::path] / ] 1 ] switch $path_seg1 { "abc" - "def" - "ghi" { Rewrite Host header HTTP::header replace Host "${path_seg1}.com" Rewrite path to remove first segment (not sure if this is actually your requirement) if {[substr [HTTP::path] 4 ] starts_with "/"} { HTTP::path [substr [HTTP::path] 4 ] } else { HTTP::path "/" } pool "pl_{$path_seg1}_http" } default { Return 404 for not found path HTTP::respond 404 noserver content {404 - Page Not FoundWe're sorry - the page you are looking for cannot be found} return } } }
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