A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://cloud.google.com/load-balancing/docs/url-map-concepts below:

URL maps overview | Load Balancing

Google Cloud Application Load Balancers and Cloud Service Mesh use a Google Cloud configuration resource called a URL map to route HTTP(S) requests to backend services or backend buckets.

For example, with an external Application Load Balancer, you can use a single URL map to route requests to different destinations based on the rules configured in the URL map:

URL maps are used with the following Google Cloud products:

There are two types of URL map resources available: global and regional.

The type of resource that you use depends on the product's load balancing scheme.

Product Load-balancing scheme URL map resource type Supported destinations Global external Application Load Balancer EXTERNAL_MANAGED Global Backend services, backend buckets Classic Application Load Balancer EXTERNAL Global Backend services, backend buckets Regional external Application Load Balancer EXTERNAL_MANAGED Regional Backend services Cross-region internal Application Load Balancer INTERNAL_MANAGED Global Backend services Regional internal Application Load Balancer INTERNAL_MANAGED Regional Backend services Cloud Service Mesh INTERNAL_SELF_MANAGED Global Backend services

Not all URL map features are available for all products. URL maps used with global external Application Load Balancers, regional external Application Load Balancers, internal Application Load Balancers and Cloud Service Mesh also support several advanced traffic management features. For more information about these differences, see Load balancer feature comparison: Routing and traffic management. In addition, regional URL maps can be a resource that's designated as a service in App Hub applications.

How URL maps work

When a request arrives at the load balancer, the load balancer routes the request to a particular backend service or a backend bucket based on the rules defined in the URL map.

A backend service represents a collection of backends, which are instances of an application or microservice. A backend bucket is a Cloud Storage bucket, which is commonly used to host static content, such as images.

For regional external Application Load Balancers, internal Application Load Balancers, and Cloud Service Mesh, possible destinations are the following:

Additionally, global external Application Load Balancers support the following:

For example, assume that you have the following setup:

You want the following to happen:

A --path-rule for /video/* matches URIs such as /video/test1 and /video/test2. However, this path rule doesn't match the path /video.

If the load balancer receives a request with /../ in the URL, the load balancer transforms the URL by removing the path segment before the .., and responds with the transformed URL. For example, when a request is sent for http://example.net/video/../abc, the load balancer responds with a 302 redirect to http://example.net/abc. Most clients then react by issuing a request to the URL returned by the load balancer (in this case, http://example.net/abc). This 302 redirection isn't logged in Cloud Logging.

The URL map lets you set up this type of host and path-based routing.

Example backend service setup (click to enlarge). Load balancer naming

For Application Load Balancers, the name of the load balancer is always the same as the name of the URL map. The behavior for each Google Cloud interface is as follows:

To learn about how naming works for Proxy Network Load Balancers and Passthrough Network Load Balancers, see Backend services overview: Load balancer naming.

URL map components

A URL map is a set of Google Cloud configuration resources that direct requests for URLs to backend services or backend buckets. The URL map does so by using the hostname and path portions for each URL it processes:

Load balancer configuration with basic URL map (click to enlarge).

This diagram shows the structure of the load balancing configuration objects in relation to each other.

Note: The diagram isn't intended to show the processing flow for requests.

You control which backend services or backend buckets receive incoming requests by using the following URL map configuration parameters:

Note: Backend buckets are not supported with internal Application Load Balancers and Cloud Service Mesh. Order of operations

For a given hostname and path in a requested URL, Google Cloud uses the following procedure to direct the request to the correct backend service or backend bucket, as configured in your URL map:

Path matcher constraints

Hostnames, path matchers, and path rules have constraints.

Wildcards, regular expressions, and dynamic URLs in path rules Wildcards and pattern matching operators in path templates for route rules

Flexible pattern matching operators let you match multiple parts of a URL path, including partial URLs and suffixes (file extensions), by using wildcard syntax. These operators can be helpful when you need to route traffic and execute rewrites based on complex URL paths. You can also associate one or more path components with named variables and then refer to those variables when rewriting the URL. With named variables, you can reorder and remove URL components before the request is sent to your origin.

Pattern matching with wildcards is supported only for the following products:

The following example routes traffic for an eCommerce application that has separate services for cart information and user information. You can configure routeRules with flexible pattern matching operators and named variables to send the user's unique ID to a user account details page and the user's cart information to a cart processing service after rewriting the URL.

  pathMatchers:
    - name: cart-matcher
      routeRules:
        - description: CartService
          matchRules:
            - pathTemplateMatch: '/xyzwebservices/v2/xyz/users/{username=*}/carts/{cartid=**}'
          service: cart-backend
          priority: 1
          routeAction:
            urlRewrite:
              pathTemplateRewrite: '/{username}-{cartid}/'
    - name: user-matcher
      routeRules:
        - description: UserService
          matchRules:
            - pathTemplateMatch: '/xyzwebservices/v2/xyz/users/*/accountinfo/*'
          service: user-backend
          priority: 1

Here's what happens when a client requests /xyzwebservices/v2/xyz/users/abc@xyz.com/carts/FL0001090004/entries/SJFI38u3401nms?fields=FULL&client_type=WEB, which has both user information and cart information:

  1. The request path matches the pathTemplateMatch within the cart-matcher pathMatcher. The {username=*} variable matches abc@xyz.com and the {cartid=**} variable matches FL0001090004/entries/SJFI38u3401nms.
  2. The query parameters are split off from the path, the path is rewritten based on pathTemplateRewrite, and the query parameters are appended to the rewritten path. We must only use the same variables that we used to define the pathTemplateMatch in our pathTemplateRewrite.
  3. The rewritten request is sent to cart-backend with the rewritten URL path: /abc@xyz.com-FL0001090004/entries/SJFI38u3401nms?fields=FULL&client_type=WEB.

The following happens when a client requests /xyzwebservices/v2/xyz/users/abc%40xyz.com/accountinfo/abc-1234 instead, which has only user and account information:

  1. The request path matches the pathTemplateMatch within the user-matcher pathMatcher. The first * matches abc%40xyz.com and the second * matches abc-1234.
  2. The request is sent to user-backend.

The following table outlines the syntax for path template patterns.

Operator Matches * A single path segment, not including the surrounding path separator / characters. ** Matches zero or more characters, including any path separator / characters between multiple path segments. If other operators are included, the ** operator must be the last operator. {name} or {name=*} A named variable matching one path segment. Matches a single path segment, not including the surrounding path separator / characters. {name=news/*} A named variable explicitly matching two path segments: news and a * wildcard segment. {name=*/news/*} A named variable matching three path segments. {name=**} A named variable matching zero or more characters. If present, must be the last operator.

When you use these operators for flexible pattern matching, keep these considerations in mind:

To execute an optional URL rewrite before the request is sent to the origin, you can use the same variables that you defined to capture a path. For example, you can reference, reorder, or omit variables in the pathTemplateRewrite field when defining urlRewrite.

When you use variables and operators for flexible pattern matching for URL rewrites, keep these considerations in mind:

Hostname and host rule relationship The relationship between hostnames and host rules (click to enlarge). Host rule and path matcher relationship

The following diagram illustrates these points.

The relationship between host rules and path matchers (click to enlarge). URL and backend relationship

Each unique URL is directed to only one backend service or backend bucket. Consequently:

URL maps and protocols

You can use the same URL map, host rules, and path matchers to process both HTTP and HTTPS requests submitted by clients, as long as both a target HTTP proxy and a target HTTPS proxy reference the URL map.

Simplest URL map

The simplest URL map only has a default backend service or a default backend bucket. It contains no host rules and no path matchers. Either the default backend service or the default backend bucket (whichever one you defined) handles all requested URLs.

If you define a default backend service, Google Cloud directs requests to its backend instance groups or backend NEGs according to the backend service's configuration.

URL map with no rules except default (click to enlarge). Example URL map workflow with an external Application Load Balancer

The following example illustrates the order of operations for a URL map. This example configures only the URL map for an existing classic Application Load Balancer. For conceptual simplicity, it only uses backend services; however, you can substitute backend buckets instead. To learn how to create the load balancer's other components, see Create a classic Application Load Balancer.

For more information about creating and configuring URL maps with path matchers and host rules, see the gcloud compute url-maps create documentation.

  1. Create a URL map for the load balancer and specify a default backend service. This example creates a URL map named video-org-url-map that references an existing backend service named org-site.

    gcloud compute url-maps create video-org-url-map \
        --default-service=org-site
    
  2. Create a path matcher named video-matcher with the following characteristics:

    gcloud compute url-maps add-path-matcher video-org-url-map \
        --path-matcher-name=video-matcher \
        --default-service=video-site \
        --path-rules=/video/hd=video-hd,/video/hd/*=video-hd,/video/sd=video-sd,/video/sd/*=video-sd
    
  3. Create a host rule for the example.net hostname that references the video-matcher path matcher.

    gcloud compute url-maps add-host-rule video-org-url-map \
        --hosts=example.net \
        --path-matcher-name=video-matcher
    

The video-org-url-map URL map should look like this:

gcloud compute url-maps describe video-org-url-map
creationTimestamp: '2021-03-05T13:34:15.833-08:00'
defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/org-site
fingerprint: mfyJIT7Zurs=
hostRules:
- hosts:
  - '*'
  pathMatcher: video-matcher
- hosts:
  - example.net
  pathMatcher: video-matcher
id: '8886405179645041976'
kind: compute#urlMap
name: video-org-url-map
pathMatchers:
- defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-site
  name: video-matcher
  pathRules:
  - paths:
    - /video/hd
    - /video/hd/*
    service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-hd
  - paths:
    - /video/sd
    - /video/sd/*
    service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendServices/video-sd
selfLink: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/video-org-url-map

The video-org-url-map URL map directs requested URLs to backends in the following way.

URL map with a path rule, path matchers, and a host rule (click to enlarge).

The following table explains the request processing shown in the preceding diagram.

Hostname URL paths Selected backend service Reason for selection Hostname:
example.org and all other hostnames different from
example.net all paths org-site The hostname is not in any host rule of the URL map, so the request is directed to the URL map's default backend service. Hostname:
example.net /video
/video/examples video-site The request goes to the default backend service because there is no path rule for /video/ or /video/*. The host rule for example.net references a path matcher, but that path matcher does not have any path rules that would apply to these paths. Hostname:
example.net /video/hd
/video/hd/movie1
/video/hd/movies/movie2
Other URLs that begin with /video/hd/* video-hd A host rule for example.net references a path matcher whose path rules direct requests for URL paths that either exactly match /video/hd or that begin with /video/hd/* to the video-hd backend service. Hostname:
example.net /video/sd
/video/sd/show1
/video/sd/shows/show2
Other URLs that begin with /video/sd/* video-sd A host rule for example.net references a path matcher whose path rules direct requests for URL paths that either exactly match /video/sd or that begin with /video/sd/* to the video-sd backend service. URL redirects

A URL redirect redirects your domain's visitors from one URL to another.

A default URL redirect is not conditioned on matching any particular pattern in the incoming request. For example, you might want to use a default URL redirect to redirect any hostname to a hostname of your choice.

There are several ways to create a URL redirect, as outlined in the following table.

Method Configuration URL map's default URL redirect Top-level defaultUrlRedirect A path matcher's default URL redirect pathMatchers[].defaultUrlRedirect[] A path matcher's path rule's URL redirect pathMatchers[].pathRules[].urlRedirect A path matcher's route rule's URL redirect pathMatchers[].routeRules[].urlRedirect

Inside of a defaultUrlRedirect or urlRedirect, pathRedirect always works as follows:

Inside of a defaultUrlRedirect or urlRedirect, how theprefixRedirect works depends on how you use it:

Redirect examples

The following table provides some examples of redirect configurations. The right-hand column shows the API configuration for a default URL redirect.

You want Accomplished using a default URL redirect HTTP-to-HTTPS redirect

Redirect


http://host.name/path
to
https://host.name/path
            kind: compute#urlMap
            name: web-map-http
            defaultUrlRedirect:
              httpsRedirect: True
           
HTTP-to-HTTPS + Host redirect

Redirect


http://any-host-name/path
to
https://www.example.com/path
            kind: compute#urlMap
            name: web-map-http
            defaultUrlRedirect:
              httpsRedirect: True
              hostRedirect: "www.example.com"
          
HTTP-to-HTTPS + Host redirect + Full path redirect

Redirect


http://any-host-name/path
to
https://www.example.com/newPath
            kind: compute#urlMap
            name: web-map-http
            defaultUrlRedirect:
              httpsRedirect: True
              hostRedirect: "www.example.com"
              pathRedirect: "/newPath"
           
HTTP-to-HTTPS + Host redirect + Prefix redirect

Redirect


http://any-host-name/originalPath
to
https://www.example.com/newPrefix/originalPath
            kind: compute#urlMap
            name: web-map-http
            defaultUrlRedirect:
              httpsRedirect: True
              hostRedirect: "www.example.com"
              prefixRedirect: "/newPrefix"
            

The following partial snippet annotates each API resource:

defaultUrlRedirect:
   redirectResponseCode: MOVED_PERMANENTLY_DEFAULT
   httpsRedirect: True # True if you want https://, false if you want http://
   hostRedirect: "new-host-name.com" # Omit to keep the requested host
   pathRedirect: "/new-path" # Omit to keep the requested path; mutually exclusive to prefixRedirect
   prefixRedirect: "/newPrefix" # Omit to keep the requested path; mutually exclusive to pathRedirect
   stripQuery: False # True to omit everything in the URL after ?
   ...
What's next

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4