Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTTPS Load Balancer backend URL mapping fails to load the rendering page

My applications uses HTTPS to run all services using docker-compose.

The application runs without any issues and we are trying to setup a HTTPS Load Balancer for all the services.

We created a Load Balancer using this Documentation.

We added three backend services and have set Host and path rules for all backend services.

HTTPS_Loadbalancer

But when trying to view below HTTPS URL's

https://Loadbalancer-ip:/strapi

https://Loadbalancer-ip:/auth

https://Loadbalancer-ip:/images/1.

I am getting the 404 page. But it works alone for All unmatched (default) alone.

like image 548
klee Avatar asked Feb 05 '21 04:02

klee


People also ask

What is URL map in load balancer?

A URL map is a set of rules for routing incoming HTTP(S) requests to specific backend services or backend buckets.

How many https load balancing backends would you need to support one version each of three different Microservices each with two Migs in two different regions?

The load balancer requires two backend services and a health check to service both of them. In this example, the load balancer terminates HTTPS requests from the client and uses HTTP to communicate with the backends.

How does a URL map work in a load balancer?

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.

Why is my load balancer failing to connect to my application?

If your application hosted in the backend VM of a load balancer is trying to access another application hosted in the same backend VM over the same network interface, it's an unsupported scenario and will fail. Configure separate backend pool VMs per application.

How do I update the backend of a load balancer?

Click the Name of a load balancer. On the Load Balancer Details screen, click Edit edit for the selected load balancer. In the Host and path rules screen, in the Backends field pull-down menu, select an available backend service or backend bucket. Look for the blue checkmark to the left of Host and Path Rules and click the Update button.

How do I redirect HTTP requests to HTTPS in load balancer?

Select a load balancer, and then choose HTTP Listener. Under Rules, choose View/edit rules. Choose Edit Rule to modify the existing default rule to redirect all HTTP requests to HTTPS. Or, insert a rule between the existing rules (if appropriate for your use case).


1 Answers

I want to help you to fix your current limitation.

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

Before deploying a URL map, make sure you validate the URL map configuration to ensure that the map is routing requests to the appropriate backends as intended. You can do this by adding tests to the URL map configuration.

Use the gcloud compute url-maps validate command to validate URL map configuration.


gcloud compute url-maps validate --source PATH_TO_URL_MAP_CONFIG_FILE

PATH_TO_URL_MAP_CONFIG_FILE: Replace with a path to the file that contains the URL map configuration for validation.

Validating changes to an existing load balancer's URL map

If you have an existing load balancer that needs changes to the URL map, you can test those configuration changes before making them live.

  1. Export the load balancer's existing URL map to a YAML file.
gcloud compute url-maps export URL_MAP_NAME \
   --destination PATH_TO_URL_MAP_CONFIG_FILE \
   --global

  1. Edit the YAML file with new configuration. For example, if you want to edit an external HTTP(S) load balancer and send all requests with the path /video to a new backend service called video-backend-service, you can add tests to the URL map configuration as follows:

Existing URL map configuration with a single default web-backend-service:

 kind: compute#urlMap
 name: URL_MAP_NAME
 defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/web-backend-service

Edited URL map configuration with added path matcher and tests for both the default web-backend-service and the new video-backend-service backend service:

 kind: compute#urlMap
 name: URL_MAP_NAME
 defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/web-backend-service
 hostRules:
 - hosts:
   - '*'
   pathMatcher: pathmap
 pathMatchers:
 - defaultService: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/web-backend-service
   name: pathmap
   pathRules:
   - paths:
     - /video
     - /video/*
     service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/video-backend-service
 tests:
 - description: Test routing to existing web service
   host: foobar
   path: /
   service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/web-backend-service
 - description: Test routing to new video service
   host: foobar
   path: /video
   service: https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/backendService/video-backend-service
  1. Validate the new configuration.
gcloud compute url-maps validate --source PATH_TO_URL_MAP_CONFIG_FILE

If all tests pass successfully, you should see a success message such as:

Successfully validated [https://www.googleapis.com/compute/v1/projects/PROJECT_ID/global/urlMaps/URL_MAP_CONFIG_FILE_NAME

If the tests fail, an error message appears. Make the required fixes to the URL map config file and try validating again.

Error: Invalid value for field 'urlMap.tests': ''.
Test failure: Expect URL 'HOST/PATH' to map to service 'EXPECTED_BACKEND_SERVICE', but actually mapped to 'ACTUAL_BACKEND_SERVICE'.
  1. Once you know that the new configuration works and does not impact your existing setup, you can import it into the URL map. Note that this step will also deploy the url map with the new configuration.
gcloud compute url-maps import URL_MAP_NAME \
   --source PATH_TO_URL_MAP_CONFIG_FILE \
   --global

Important: If you originally set up your load balancer in the Cloud Console, the URL map name is the same as your load balancer's name.

Have fun!

like image 200
Arden Smith Avatar answered Oct 17 '22 15:10

Arden Smith