Send traffic from different url's to specific servers

0

Hi,

I try to match specific URL's to specific servers. like this:
xyz.com        ---> server1
xyz.com/two ---> server2
test.xyz.com ---> server3

My rules at the moment:
Rule1: /"xyz.com$/
Rule2: /^\/two/
Rule3: /^test.xyz.com$/

Rule1 matched to server1 (xyz.com) Sharepoint
Rule 2 matched to server2 (xyz.com/two) sap
Rule 3 matched to server3 (test.xyz.com) random web service

This works, but test.xyz.com is able to access /two with test.xyz.com/two But only xyz.com should be able to do this xyz.com/two.
Is there any way to match a specific portion of a string?
I thought that /^test.xyz.com$/ was read like this - ^ is start of match and $ is end of match, but it does not seem to work like that because that would mean that test.xyz.com/two is not a match to rule 3. But it is :(

Hope you understand what i try to accomplish and can help. 


3 comments

Avatar
Nick Smylie Official comment

Hi Tso,

On your matching rules are you matching on Host Header or are you using the checkbox 'Include Host in URL'?  For your scenario you should be matching on Host Header for rule 1 and 3.  For Rule 2 you should you should leave the header field blank.  When left blank it matches the URL, and by this I mean anything after the .com or .org.

Another thing to take note is that your rule precedence might need to be looked at it.  This is going to be within the virtual service itself under advanced properties.  If rule 2 is higher then rule 3 it will match and not go any further and thus get the results you are experiencing right now.

Avatar
0
tso

Hi Nick,

Thank you very much. The problem was the order of the rules.

These rules and this order made it work as intended :)

Options - Header - Pattern
Ignore Case - Host - /test.xyz.com/
Ignore Case + Add Host - blank - /two/
Ingore Case - Host - /^xyz\.com$/
Ignore Case - Host - /^www\.xyz\.com$/

Another question i have is: The second rule i have" Ignore Case + Add Host - blank - /two/ " How come that this does not match test.xyz.com/two?
it is good that it doesn't but, from what i understand the "Add Host" option appends the hostname to the string så the request would be test.xyz.com/two/ but still it does not match rule 2? 

Avatar
0
Nick Smylie

Hi Tso,

If I understand you correctly that is a slight misconfiguration in itself.  The 'Add host' checkbox is there if you want to match a URL tied with a host name.  For example the match string would be...

test.com/two

It would match the whole string and not just the URL or the host name, but both together.