Forum Discussion
Mohamed_Saalih_
Nimbostratus
Apr 02, 2014Required 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 outs...
IheartF5_45022
Nacreous
Apr 02, 2014I'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
DevCentral Quicklinks
* 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
Discover DevCentral Connects