Forum Discussion
Irule URL matching issue.
Hi I am having an issue with the Irule below on the string matching on the URL.
it seems the word "dev" is being matched by the first clause, and dropping to Pool number 1 instead of going past and going to pool number 2 ..
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::host]] { "admindev.mysite.com" { pool number1 } "dev.mysite.com" { pool number2 } } }
9 Replies
- Alexander_Dube_
Altocumulus
Hi,
you can try to swap both cases. Try to match dev.mysite.com before admindev.mysite.com. This would avoid to match admindev.mysite.com when calling dev.mysite.com
I dont know if a switch is accepting regex as criteria, but with an if you can use the following:
when HTTP_REQUEST { if { [string tolower [HTTP::host]] matches_regex "^admindev.mysite.com" } { pool number1 } if { [string tolower [HTTP::host]] matches_regex "^dev.mysite.com" } { pool number2 }Regards
- Robert_Luechte1
Nimbostratus
Based off of the code snippet you've provided I don't see why you would need the -glob option, but I don't think that is causing your issue. With the way you have this configured, I don't see any way that dev.mysite.com would match your first case.
Do you have a default pool defined on your virtual server, and if so, is it pool 1? Maybe you're not matching either of your cases in your switch statement and you are just going to the default pool.
If I were you, I would put some log statements in to determine the path you are taking. Something like this:
when HTTP_REQUEST { log local0. "Host header is [HTTP::host]" switch [string tolower [HTTP::host]] { "admindev.mysite.com" { log local0. "matched admindev.mysite.com" pool number1 } "dev.mysite.com" { log local0. "matched dev.mysite.com" pool number2 } } }- HI, there is no Default Pool on the VS.. Ill try the logging but I have to wait for a Change control as its on Production kit .. I am considering that switching the order might prove the issue without the logging.
- Robert_Luechte1
Nimbostratus
Maybe, but you don't have any wildcards in your example above so it should only be an exact match. Or does your actual code have wildcard symbols in the switch cases? - I removed the wildcards as I thought the same thing.. but its didn't fix the issue.. im going to re-order the rule this evening so ill see if that solves the issue, otherwise Ill be logging it out.
Based off of the code snippet you've provided I don't see why you would need the -glob option, but I don't think that is causing your issue. With the way you have this configured, I don't see any way that dev.mysite.com would match your first case.
Do you have a default pool defined on your virtual server, and if so, is it pool 1? Maybe you're not matching either of your cases in your switch statement and you are just going to the default pool.
If I were you, I would put some log statements in to determine the path you are taking. Something like this:
when HTTP_REQUEST { log local0. "Host header is [HTTP::host]" switch [string tolower [HTTP::host]] { "admindev.mysite.com" { log local0. "matched admindev.mysite.com" pool number1 } "dev.mysite.com" { log local0. "matched dev.mysite.com" pool number2 } } }- HI, there is no Default Pool on the VS.. Ill try the logging but I have to wait for a Change control as its on Production kit .. I am considering that switching the order might prove the issue without the logging.
- Maybe, but you don't have any wildcards in your example above so it should only be an exact match. Or does your actual code have wildcard symbols in the switch cases?
- I removed the wildcards as I thought the same thing.. but its didn't fix the issue.. im going to re-order the rule this evening so ill see if that solves the issue, otherwise Ill be logging it out.
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