In the Application Control Engine Module Command Reference manual,
the section about "Class Map HTTP Load Balancing Configuration Mode Commands"
mentions for "(config-cmap-http-lb) match http url" that
| Usage Guidelines
| Include only the portion of the URL following http://www.hostname.domain in
| the match statement. For example, in the URL
| http://www.anydomain.com/latest/whatsnew.html, include only
| /latest/whatsnew.html. To match the http://www.anydomain.com portion, the
| URL string can take the form of a URL regular expression.
It is a bit contradictory, but my interpretation of this explanation is
that if one uses a regular expression pattern it could match the
hostname portion of the URL. I tried, among others, the following
patterns to no avail:
match http url www[.]hostname[.]domain/.*
match http url /www[.]hostname[.]domain/.*
match http url //www[.]hostname[.]domain/.*
match http url http://www[.]hostname[.]domain/.*
- What is the proper pattern to use to match the hostname portion?
- Is there a way to debug pattern matching (i.e. see what is the input
to match and which "match http url" line matched)?
I would like to use this in order to direct HTTP queries to different
servers depending on specific combinations of (apache virtual) host
and path. One could use
(config-cmap-http-lb) match http header Host header-value www[.]hostname[.]domain
but then one is forced to use "match-all", which becomes very
cumbersome if there are many virtual hosts and a lot of paths patterns
for the same virtual host.
Incidently, the table describing regular expression characters
does not mention "(expr)? Zero or one of expression". It works and is
very useful; e.g:
match http url "/path_with_or_without_trailing_slash(/.*)?"
Thanks in advance for you help!
URL is the piece that comes after the HTTP method in the HTTP request
from the client. Since that will not contain the hostname (unless the
request is destined for an HTTP proxy), you will need to read the
hostname from the host header.
If you look at a HTTP request it looks like
GET /index.htm HTTP/1.1\r\n <-- This is the url
Host:www.cisco.com <-- This is the HOST
If you want to match these two conditions then you need to math both HOST and URL.
The syntax would look like:
class-map type http loadbalance match-all xyz
2 match http header Host header-value www[.]cisco[.]com
3 match http url /index.htm
Syed Iftekhar Ahmed