config : server-policy http-content-routing-policy
 
server-policy http-content-routing-policy
Use this command to configure HTTP header-based routing.
Instead of dynamically routing requests to a server pool simply based upon load or connection distribution at the TCP/IP layers, as basic load balancing does, you can forward them based on headers in the HTTP layer.
HTTP header-based routes define how FortiWeb routes requests to server pools. They are based on one or more of the following HTTP header elements:
Host
HTTP Request
Referer
Source IP
cookie
This type of routing can be useful if, for example, a specific web server or group of servers on the back end support specific web applications, functions, or host names. That is, your web servers or server pools are not identical, but specialized. For example:
192.168.0.1 — Hosts the web site and blog
192.168.0.2 and 192.168.0.3 — Host movie clips and multimedia
192.168.0.4 and 192.168.0.5 — Host the shopping cart
If you have configured request rewriting, configure HTTP content-based routing using the original request URL and/or Host: name, as it appears before FortiWeb has rewritten it. For more information on rewriting, see “config waf url-rewrite url-rewrite-policy”.
To apply your HTTP-based routes, select them when you configure the server policy (see “server-policy policy”).
To use this command, your administrator account’s access control profile must have either w or rw permission to the traroutegrp area. For more information, see “Permissions”.
Syntax
config server-policy http-content-routing-policy
edit <routing-policy_name>
set server-pool <server-pool_name>
config content-routing-match-list
edit <entry_index>
set match-object {HTTP-HOST | HTTP-Referer | HTTP-Request | HTTP-Request-Cookie | Source-IP | }
set match-condition {Match-Begin | Match-End | Match-Sub | Match-Domain | Match-Dir | Match-Reg}
set match-string <match_str>
set regular-expression <object_pattern>
set cookie-name-reg <cookie-name_str>
set cookie-value-reg <cookie-val_str>
next
end
next
end
Variable
Description
Default
<routing-policy_name>
Type the name of the HTTP content routing policy. The maximum length is 63 characters.
To display the list of existing policies, type:
edit ?
No default.
server-pool <server-pool_name>
Type the name of the server pool to which FortiWeb forwards traffic when the traffic matches rules in this policy.
For more information, see “config server-policy server-pool”.
No default.
<entry_index>
Type the index number of the individual rule in the table. The valid range is from 1 to 9,999,999,999,999,999,999.
No default.
match-object {HTTP-HOST | HTTP-Referer | HTTP-Request | HTTP-Request-Cookie | Source-IP | }
Type the type of object that FortiWeb examines for matching values:
HTTP-HOSTHost: field
HTTP-RefererReferer: field
HTTP-Request — Request URL
HTTP-Request-Cookie — HTTP Request Cookie
Source-IP — Source IP address of request
No default.
match-condition {Match-Begin | Match-End | Match-Sub | Match-Domain | Match-Dir | Match-Reg}
Type the type of value to match. Values can be a literal value that appears in the object or a regular expression.
The value of match-object determines which content types you can specify.
If match-object is HTTP-HOST, HTTP-Request, or HTTP-Referer only:
Match-Begin — The object to match begins with the specified string.
Match-End — The object to match ends with the specified string.
Match-Sub — The object to match contains the specified string.
If match-object is HTTP-HOST only:
Match-Domain — The object to match contains the specified string between the periods in a domain name.
For example, if match-string is abc, the condition matches the following hostnames:
dname1.abc.com
dname1.dname2.abc.com
However, the same Match Simple String value does not match the following hostnames:
abc.com
dname.abc
If match-object is HTTP-Request or HTTP-Referer only:
Match-Dir — The object to match contains the specified string between delimiting characters (slash) in a domain name.
For example, if match-string is abc, the condition matches the following hostnames:
test.com/abc/
test.com/dir1/abc/
http://test.abc.com/
However, the same match-string value does not match the following hostnames:
test.com/abc
test.abc.com
For all object types:
Match-Reg — The object to match has a value that matches the specified regular expression.
No default.
match-string <match_str>
Specifies a value to match in the object element specified by match-object and match-condition.
Available when the condition to match is a prefix, suffix, part of the domain name, or other literal object value.
For example, a literal URL, such as /index.php, that a matching HTTP request contains.
No default.
regular-expression <object_pattern>
Specifies a regular expression to match a value in the object element specified by match-object and match-condition.
Available when the value of match-condition is Match-Reg.
For example, an expression, such as ^/*.php, that matches a URL.
Tip: When you enter a regular expression using the web UI, you can validate its syntax.
No default.
cookie-name-reg <cookie-name_str>
Type a regular expression to match the name of the cookie that appears in an HTTP header.
For example, the name of a cookie embedded by traffic controller software on one of the servers.
Available when the value of match-object is HTTP-Request.
Tip: When you enter a regular expression using the web UI, you can validate its syntax.
No default.
cookie-value-reg <cookie-val_str>
Enter a regular expression that matches all and only the cookie values you want the rule to apply to.
For example, hash[a-fA-F0-7]*.
Available when the value of match-object is HTTP-Request.
Tip: When you enter a regular expression using the web UI, you can validate its syntax.
No default.
Example
This example configures an HTTP content routing policy to route URL requests for www.example.com/school to the server pool school-site. The content routing is based on matching a regular expression in a URL and/or cookie.
config server-policy http-content-routing-policy
edit content_routing_policy1
set server-pool school-site
config content-routing-match-list
edit 1
set match-condition Match-Domain
set match-string \/example.com
next
edit 2
set match-object HTTP-Request-Cookie
set match-condition Match-Reg
set cookie-name-reg sessid
set cookie-value-reg hash[a-fA-F0-7]*
next
end
next
end
Related topics
config server-policy server-pool
config server-policy policy
config waf url-rewrite url-rewrite-policy