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

Viewed 270

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.

2 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!

  1. Would you mean the page with status code 404, Or just can not access to your page?

  2. Please make sure you have specified the right ip AND port of backend services.

  3. Do you want to map Loadbalancer-ip:/strapi to service-ip:/strapi or service-ip:?

Related