Forum Discussion
Leonjsr_323498
Nimbostratus
Jun 09, 2017iRule Question
Hi
I created an rule to send traffic to sub.domain.com to a particular node 1.1.1.1 and that works fine. But I need any other traffic either destined to the same domain name, domain.com to go to a different node 1.1.1.2 which may include the default webpage without host headers.
Is there a way to accomplish this? I checked around couldn't find an answer. Any example code appreciated.
Thanks
when HTTP_REQUEST {
if { [HTTP::header "Host"] starts_with "sub.domain.com" } {
snatpool SNAT
node 1.1.1.1 80
}
elseif { [HTTP::host] contains "domain.com" } {
snatpool SNAT
node 1.1.1.2 80
}
}
- cjunior
Nacreous
Hello, I'm not sure when you haven't a host header, so Is this what your are trying to do?
when HTTP_REQUEST { if { [getfield [HTTP::host] ":" 1] ends_with "sub.domain.com" } { snatpool SNAT node 1.1.1.1 80 } elseif { [HTTP::host] contains "domain.com" || [HTTP::path] contains "domain.com" } { snatpool SNAT node 1.1.1.2 80 } }
Test 1:
GET /path1/page HTTP/1.1 Host: www.sub.domain.com Connection: close
Test 2:
GET /path1/page HTTP/1.1 Host: www.domain.com Connection: close
Test 3:
GET http://www.domain.com/path1/page HTTP/1.0
Regards
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