Layer-7 forwarding domain name and URL rule description

Last Updated At: 2025-10-21 09:10:00

Business Flow Chart

The layer-7 and layer-4 business flow chart of the CLB are as follows:

When using the layer-7 forwarding HTTP/HTTPS protocol of the CLB , create a new forwarding rule in the listener of a CLB instance, and the user can add a corresponding domain name.

  • When the user has only established one forwarding rule, accessing the VIP+ URL can correspond to the corresponding forwarding rule and access the service normally.
  • When the user has established multiple forwarding rules, accessing VIP + URL at this time cannot ensure access to a specific domain name + URL. The user needs to directly access the domain name + URL to ensure that the specific forwarding rules are effective. That is, when the user configures multiple forwarding rules, the same VIP corresponds to multiple domain names. In this case, it is not recommended to access the service through VIP + URL, but to access the service through specific domain name + URL.

Forwarding rule configuration instructions

Domain name configuration rules

When configuring the domain name in the forwarding rule of the CLB layer-7 listener, you can use regular expressions but the length is limited to 1 - 120.

  • The character sets supported by irregular domain names are as follows:
    az``0-9``.``-
  • Wildcard domain name, currently only supports *.example.com or www.example.*. And only one occurrence of < 5 > * </5 > is supported in a single domain name.
  • Regular expressions are supported. The character sets that are not supported in regular expressions are as follows:
    "``{``}``;``\ ``` ~`````Space.
  • Examples of regular domain names supported by the CLB are as follows:
    ~^www\d+\.example\.com$

Health check configuration rules

  • When the domain name filled in by the user is a wildcard domain name, you need to specify a fixed domain name (non-regular) as the health check domain name. The character sets supported by the health check domain name configuration are as follows:
    a-z``0-9``.``-
  • When configuring the health check path for the load balancing layer-7 listener, the default is /, must be preceded by / The length limit is 1 - 120. Regular expressions are not supported yet. It is recommended to specify a fixed URL path (static page) for health check. The character sets supported by the health check path configuration are as follows:
    a-z``A-Z``0-9``.``-``/``=``?

Domain Name Matching Rules

  1. Do not configure a domain name in the forwarding rule, fill in the IP instead, and configure multiple URLs in the forwarding group. The service is accessed through VIP + URL.
  2. Configure the full domain name in the forwarding rule and configure multiple URLs in the forwarding group. The service is accessed through the domain name + URL.
  3. Configure a wildcard domain name in the forwarding rule and configure multiple URLs in the forwarding group to access by matching the request domain name + URL. When users want different domain names to point to the same URL address, they can refer to this configuration method. Take example.test.com as an example, the format is as follows:
  • example.test.com exactly match example.test.com domain name.
  • \*.test.com matches all domain name ending with test.com.
  • example.test.\* matches all the domain names starting with example.test .
  1. Configure the domain name in the forwarding rule and configure the fuzzy matching URL in the forwarding group. With prefix matching, you can add the wildcard $ at the end for a full match.
    For example, the user configures the forwarding group URL ~* \.(gif|jpg|bmp)$ , hoping to match any file ending with gif, jpg, or bmp.

Default domain policy in forwarding domain name

You can choose to turn the default domain name on or off.

  • Enable: When the client request does not match any domain name of this listener, CLB will forward the request to the default domain name (Default Server). Each listener can only be configured with one default domain name.
    • If your layer-7 listener has been configured with a default domain name, client requests that do not match other rules will be forwarded to the default domain name.
    • If your layer-7 listener is not configured with a default domain name, client requests that do not match other rules will be forwarded to the first domain name loaded by the CLB. Since the loading order may be inconsistent with the console configuration order, it is not necessarily the first one configured by the console.
  • Disable: When the client request does not match any domain name of this listener, the request will not be forwarded.

For example, in CLB1's HTTP:80, two domain names are configured under the listener: www.test1.com, www.test2.com, where www.test1.com is the default domain name. When a user visits www.example.com, since no domain name is matched, CLB will forward the request to the default domain name www.test1.com.

Forwarding group URL matching rules description

URL Configuration Rules

CLB layer-7 listener forwards a path URL,with / by default. The URL must be preceded by /, with a length range of 1 - 120. For the forwarding path URL of a CLB layer-7 listener, the default URL should start with a forward slash '/'. The length must be between 1 to 120 characters.

  • URL supports regular expressions, which can be understood by the following explanations:
  • Beginning with = indicates an exact match.
  • Beginning with ^~ means that the URL starts with a regular character string, not a regular match.
  • Beginning with ~ indicates a case-sensitive regular match.
  • Beginning with ~* indicates a case-insensitive regular match.
  • / means universal matching. Any request will be matched if there is no other match.
  • Non-regular URL path starts with / supported character sets are as follows:
    az``AZ``0-9``.``-``/``=``? .
  • For regular URL, unsupported character sets are as follows:
    "``{``}``;``\ ``` ~`````Space

URL Matching Rule Examples

  1. Matching rules: priority to exact matching, then fuzzy matching according to the rules.

For example, after configuring the forwarding rules and forwarding groups according to the figure above, the following requests will be matched to different forwarding groups in turn:

  1. example.qloud.com/test1/image/index1.html Since the URL rule set by forwarding group 1 is exactly matched, the request will be forwarded to the backend CVM associated with forwarding group 1, that is, port 80 of RS1 and RS2 in the figure.
  2. example.qloud.com/test1/image/hello.html Since this request cannot exactly match the first rule, it will continue to match the rules in forwarding group 2 and finds that the fuzzy match is successful. Therefore, the request will be forwarded to the backend CVM associated with forwarding group 2, namely port 81 of RS2 and RS3 in the figure.
  3. example.qloud.com/test2/video/mp4/ Since this request cannot be exactly matched to the first two rules, it will continue to match downwards until it finds a rule in forwarding group 3 that can be fuzzily matched. Therefore, the request will be forwarded to the backend CVM associated with forwarding group 3, which is port 90 of RS4 in the figure.
  4. example.qloud.com/test3/hello/index.html Since this request cannot match the rules in the first three forwarding groups, it will match the most common rule configured by the user Default URL. At this time, Nginx forwards the request to the backend application server, such as FastCGI (php), tomcat (jsp), and Nginx exists as a reverse proxy server.
  5. example.qloud.com/test2/ Since the request cannot be matched exactly to the rules in the first three forwarding groups, it will match the user-configured general rule default URL.
  6. If the service cannot run normally in the URL rule set by the user, it will not redirect to other pages after a successful match.
    For example, the client requests example.qloud.com/test1/image/index1.html matches the URL rule of forwarding group 1, but the backend server of forwarding group 1 is running abnormally. When a 404 page appears, the page will display 404 when the user visits it, and will not jump to other pages.
  7. It is recommended that users set the Default URL, direct it to a stable service page (such as a static page, homepage), and bind it to all backend CVMs. At this time, if all rules are not matched successfully, the system will direct the request to the page where the Default URL is located, otherwise a 404 problem may occur.
  8. If the user has not set a Default URL and all forwarding rules do not match, accessing the service will return a 404 error.