Configuring content routes
You can use the content routes configuration to select the backend server pool based on matches to TCP/IP or HTTP header values.
Layer 7 content route rules are based on literal or regular expression matches to the following header values:
- HTTP Host
- HTTP Referer
- HTTP Request URL
- SNI
- Source IP address
You might want to use Layer 7 content routes to simplify front-end coding of your web pages or to obfuscate the precise server names from clients. For example, you can publish links to a simple URL named example.com and use content route rules to direct traffic for requests to example.com to a server pool that includes server1.example.com, server2.example.com, and server3.example.com.
Layer 4 content route rules are based on literal or regular expression matches to the following header values:
- Source IP address
Before you begin:
- You must have a good understanding of HTTP header fields.
- You must have a good understanding of Perl-compatible regular expressions (PCRE) if you want to use them in rule matching.
- You must have Read-Write permission for Load Balance settings.
After you have configured a content routing rule, you can select it in the virtual server configuration.
Note: You can select multiple content routing rules in the virtual server configuration. Rules you add to that configuration are consulted from top to bottom. The first rule to match is applied. If the traffic does not match any of the content routing rule conditions specified in the virtual server configuration, the system behaves unexpectedly. Therefore, it is important that you create a “catch all” rule that has no match conditions. In the virtual server configuration, this rule should be ordered last so it can be used to forward traffic to a default pool.
To configure a content route rule:
- Go to Server Load Balance > Virtual Server.
- Click the Content Routing tab.
- Click Create New to display the configuration editor.
- Enter a name for the Content Routing configuration and select the Type:
Setting
Description
Name Configuration name. Valid characters are
A
-Z
,a
-z
,0
-9
,_
, and-
. No spaces. You reference this name in the virtual server configuration.Note: After you initially save the configuration, you cannot edit the name.
Type - Layer 4
- Layer 7
The content routing settings applicable to the selected Type displays.
- If the Type is Layer 7, configure the following settings.
- Configure the General settings:
Setting
Description
Schedule Pool Enable to select a schedule pool for content routing. This is disabled by default. Schedule Pool List
The Schedule Pool List option is available if Schedule Pool is enabled.
Select the schedule pool objects.
Real Server Pool The Real Server Pool option is available if Schedule Pool is disabled.
Select the real server pool configuration.
Persistence The Persistence option is configurable if Inherit (Persistence) is disabled.
Select a session persistence type if not inheriting persistence from the virtual server.
Inherit (Persistence) Enable to use the persistence object specified in the virtual server configuration. This is enabled by default. Method The Method option is configurable if Inherit (Method) is disabled.
Select a load balancing method type if not inheriting method from the virtual server.
Inherit (Method) Enable to use the method specified in the virtual server configuration. - Click Save to commit the General settings to the Content Routing configuration.
Once the configuration is saved, the Match Condition (Empty Match Condition will match anything) section becomes configurable. - Under the Match Condition (Empty Match Condition will match anything) section, click Create New to display the configuration editor.
- Configure the Match Condition (Empty Match Condition will match anything) settings:
Setting
Description
Object Select content matching conditions based on the following parameters:
- HTTP Host Header
- HTTP Referer Header
- HTTP Request URL
- Source IP Address
- SNI
Note: When you add multiple conditions, FortiADC joins them with an AND operator. For example, if you specify both a HTTP Host Header and HTTP Request URL to match, the rule is a match only for traffic that meets both conditions.
Type The Type option is not available if Object is Source IP Address.
- String
- Regular Expression
Content Specify the string or PCRE syntax to match the header or IP address.
Note: An empty match condition matches any HTTP request.
Negative Enable to rule matches if traffic does not match the expression. This is disabled by default. Ignore Case The Ignore Case option is not available if Object is Source IP Address.
Enable to allow users to let the match be case sensitive. This is enabled by default.
- Click Save to commit the Match Condition configuration and exit from the editor.
- Configure the General settings:
- If the Type is Layer 4, configure the following settings.
- Configure the Specifics settings:
Setting
Description
Source (IPv4) Address/mask notation to match the source IPv4 address in the packet header. Source (IPv6) Address/mask notation to match the source IPv6 address in the packet header. - Configure the General settings:
Setting
Description
Schedule Pool Enable to select a schedule pool for content routing. This is disabled by default. Schedule Pool List
The Schedule Pool List option is available if Schedule Pool is enabled.
Select the schedule pool objects.
Real Server Pool The Real Server Pool option is available if Schedule Pool is disabled.
Select the real server pool configuration.
Persistence The Persistence option is configurable if Inherit (Persistence) is disabled.
Select a session persistence type if not inheriting persistence from the virtual server.
Inherit (Persistence) Enable to use the persistence object specified in the virtual server configuration. This is enabled by default. Method The Method option is configurable if Inherit (Method) is disabled.
Select a load balancing method type if not inheriting method from the virtual server.
Inherit (Method) Enable to use the method specified in the virtual server configuration. Packet Forward Method
Select the packet forwarding method:
Inherit
Full NAT
Source Pool List
The Source Pool List option is available if Packet Forward Method is Full NAT.
Select the source pool objects for packet forwarding.
- Configure the Specifics settings:
- Save the configuration.
Once saved, the new Content Routing configuration will be listed in the Content Routing page.