7

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.

Alejandro F.
  • 410
  • 3
  • 10
klee
  • 1,554
  • 2
  • 19
  • 31
  • Can you show 2 URLs, one on the default (all matches) and one on the URL mapping, to see the difference between a working and a falling request (I have an idea, but just to be sure!) – guillaume blaquiere Feb 05 '21 at 08:31
  • @guillaumeblaquiere I tried hitting the URL on browser as https://xx.xx.xx.xx/strapi 404 Not Found – klee Feb 05 '21 at 11:14
  • And what is the expected URL on your backend? – guillaume blaquiere Feb 05 '21 at 12:12
  • @guillaumeblaquiere My URL should be https://xx.xx.xx.xx/strapi. But when hitting this URL i am getting the Not Found on the page which i hit. – klee Feb 15 '21 at 12:47
  • Ok, and, if I understand correctly your question, if you remove the URL map, it works with only the default one (and the defined backend, of course). Correct? – guillaume blaquiere Feb 15 '21 at 12:54
  • I guess that's what is being conveyed – user352290 Feb 15 '21 at 17:11
  • @guillaumeblaquiere yes if i remove the URL map everything goes to default – klee Feb 16 '21 at 04:26
  • can you try to add 2 paths? for example `/strapi` and `/strapi/*` – guillaume blaquiere Feb 16 '21 at 07:31
  • @guillaumeblaquiere I have tried adding two differnet paths, but the message i am getting back is Not Found on browser window. i have tried /strapi and /strapi/* as you mentioned but getting the same Not Found issue – klee Feb 16 '21 at 10:21
  • Can you see in your backend nodes if this 404 at least comes from proper backend node? – Maciej Perliński Feb 16 '21 at 12:33
  • It looks interesting that the load balancer consider all your backends healthy, so probably it is properly configured. Please, pay attention to the suggestion of @MaciejPerliński and review your backend logs to see if they are receiving any HTTP traffic. Does anything change if you only configure the default rule `All unmatched`, and the ones for `/strapi` and `/auth`? AFAIK, as you configured the `rocket chat-backend-service` as the default for unmatched traffic, it will be the one used if no other rules are matched, so I think there is no need to configure the rules for `/*` and `/images/*`. – jccampanero Feb 16 '21 at 13:32
  • Hey @klee can you update what is visible on the backend node in logs and if the logs comes from proper node at least? Otherwise we are unable to help. – Maciej Perliński Feb 19 '21 at 11:32

2 Answers2

1

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!

Alejandro F.
  • 410
  • 3
  • 10
0
  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:?

武状元 Woa
  • 690
  • 3
  • 10
  • 24