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.
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.
A URL map is a set of rules for routing incoming HTTP(S) requests to specific backend services or backend buckets.
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 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.
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.
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.
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).
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.
gcloud compute url-maps export URL_MAP_NAME \
--destination PATH_TO_URL_MAP_CONFIG_FILE \
--global
/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
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'.
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!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With