Forum Discussion
help making redirect irule
Im new to irules, need some help writing a irule
vip: 10.1.255.32
node: 10.13.0.61
node: 10.0.1.213
Web programer wants any http request with
http://test.com/IDSAkcelerant/…
http://test.com/LMAkcelerant/…
http://test.com/IDSAkcelerantMTG/...
to hit pool member 10.13.0.61 otherwise goto 10.0.1.213.
they just need the f5 to pass the url with the path and have it hit the page otherwise go to
node 10.0.1.213.
Thanks
9 Replies
- Mohamed_Lrhazi
Altocumulus
Might be better for you to use an HTTP class, instead of an iRule: - Gill_32697
Nimbostratus
Ok I will try. Thank you Mohamed
Web developer said he will add more path to the header. He will adding
more /something. If I do use an irule and want to add both nodes to the pool and just pass the header intact that matches only the specified /path with a "else" statement that will point to the second node. Can you tell me the irule for that.
Its just incase I need it because I want do this first thing in the morning.
Thank you.
- Gill_32697
Nimbostratus
Ok can you send me a sample of the http class rule, I'm not to good with scripting.
Web developer said he will add more path to the header.
He will adding more /something. If I do use an irule and want to add both nodes to the pool and just pass the header intact that matches only the specified /path with a "else" statement that will point to the second node. Can you tell me the irule for that.
Its just incase I need it because I want do this first thing in the morning.
Thank you.
- nitass
Employee
you can add more uri to httpclass.[root@ve10:Active] config b virtual bar list virtual bar { snat automap destination 172.28.19.79:80 ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b class uri_class list class uri_class { { "/akcelerant/" "/idsakcelerant/" "/idsakcelerantmtg/" "/lmakcelerant/" } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { set uri [HTTP::uri] if { [class match -- [string tolower $uri] starts_with uri_class] } { node 200.200.200.111 } else { node 200.200.200.101 } } when HTTP_RESPONSE { log local0. "[IP::client_addr]:[TCP::client_port] -> [clientside {IP::local_addr}]:[clientside {TCP::local_port}] -> [IP::remote_addr]:[TCP::remote_port] | $uri" } } [root@ve10:Active] config cat /var/log/ltm Oct 22 09:17:21 local/tmm info tmm[7926]: Rule myrule : 172.28.19.251:36438 -> 172.28.19.79:80 -> 200.200.200.111:80 | /Akcelerant/something Oct 22 09:17:30 local/tmm info tmm[7926]: Rule myrule : 172.28.19.251:36439 -> 172.28.19.79:80 -> 200.200.200.111:80 | /IDSAkcelerant/something Oct 22 09:17:34 local/tmm info tmm[7926]: Rule myrule : 172.28.19.251:36440 -> 172.28.19.79:80 -> 200.200.200.111:80 | /LMAkcelerant/something Oct 22 09:17:39 local/tmm info tmm[7926]: Rule myrule : 172.28.19.251:36441 -> 172.28.19.79:80 -> 200.200.200.111:80 | /IDSAkcelerantMTG/something Oct 22 09:17:42 local/tmm info tmm[7926]: Rule myrule : 172.28.19.251:36442 -> 172.28.19.79:80 -> 200.200.200.101:80 | /somethingelse/
- Gill_32697
Nimbostratus
Ok, I will try. Thank You Very Much - Mohamed_Lrhazi
Altocumulus
Ok can you send me a sample of the http class rule, I'm not to good with scripting.c - Gill_32697
Nimbostratus
Below is my irule, Im also showing the uri paths I need. I just don't know how to add more to the irule to include
the other uri paths. As you can see I've added the Akcelerate uri path. But how do I add the rest?
I know is has to contain more IF staetments, but I don't know how to write it. I new to the irules.
----- this is the irule im writing ---------------------------------------------------------
when HTTP_REQUEST {
Thanks.
- Mohamed_Lrhazi
Altocumulus
nitass is showing you how to do this with a switch statement, instead of "if" and using a data class to hold your URIs, instead of hard coding them into the iRule, which a lot better. - nitass
Employee
i agree with Mohamed. if you are not familiar with irule, you had better use httpclass.[root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { switch -glob [HTTP::uri] { "/Akcelerant/*" - "/IDSAkcelerant/*" - "/LMAkcelerant/*" - "/IDSAkcelerantMTG/*" { pool Server1-pool } default { pool Server2-pool } } } }
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