Origin Selection (Modifies Client Request)
  • 24 Jul 2024
  • 1 Minute to read
  • PDF

Origin Selection (Modifies Client Request)

  • PDF

Article summary

Overview

Configure an Origin Selection rule to direct certain client requests (such as requests from a specified user agent) to an alternate origin.

This is a Processing Stages rule that is applied to the client request. If you add this rule to a path configuration, it is important to understand the inheritance logic. Learn more about Processing Stages rules.

Configure the Rule

Here, we'll describe how to configure the rule with the Delivery Service Management UI.

API Users may choose to build the site configuration offline.

To configure an Origin Selection rule:

  1. Navigate to the Select Rule dialog.

  2. In the Select Rule dialog, choose Origin Selection.
    OriginSelectionMain80.png

  3. Create the match condition.

    Tip: See the MEL Quick Reference

  4. Configure the origin.

    Tip: Find descriptions of the origin configuration fields in these articles: Single Origin, Origin with Failover, Round Robin List.

    OriginSelectionRuleAdd80a.png

  5. Choose Add Rule.

SVTA Component: MI.ProcessingStages

When you save the site configuration, the Origin Selection rule is added to the JSON configuration as a client-request component within the MI.ProcessingStages component.

{
	"generic-metadata-type": "MI.ProcessingStages",
	"generic-metadata-value": {
		"client-request": [
			{
				"stage-metadata": [
					{
						"generic-metadata": [
							{
								"generic-metadata-type": "MI.SourceMetadataExtended",
								"generic-metadata-value": {
									"sources": [
										{
											"protocol": "https/1.1",
											"endpoints": [
												"example.alternate.origin.com"
											]
										}
									]
								}
							}
						]
					}
				],
				"match": {
					"expression": "req.h.user-agent ~= 'Mozilla'"
				}
			}
		]
	}
}


In this example, all requests that are received from a Mozilla user agent (the match condition) are redirected to example.alternate.origin.com.

Note the two nodes nested under "client-request":

  • The MI.SourceMetadataExtended object defines the origin configuration. In this example, a single origin host is configured. However, you could also configure a failover or round-robin origin type.
  • The "match" field contains the MEL expression that sets the condition for directing a request to the alternate origin. In this example, the condition is if the user-agent is Mozilla.

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.