Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Unable to access the paths on the path matcher of the url map

I created an HTTPS load balancer with the following URL map:

host_path_rules.png

 

I created an SSL certificate for my domain and connected it to the target proxy of the load balancer:

When i go to <domainname.com>, i get the expected output from the bs-video-site backend service.

However, when i go to <domainname.com/video/hd> or <domainname.com/video/sd>, i get the following error:

Not Found

The requested URL was not found on this server.


Apache/2.4.62 (Debian) Server at thestranger.cloud Port 80

====================

I have checked all my backends, and they are in an healthy state.

For the `/video/hd` path i created an instance template using the following script. the instance group points to this instance template:

 

gcloud compute instance-templates create TEMPLATE_NAME \
  --region=REGION \
  --network=NETWORK \
  --subnet=SUBNET \
  --stack-type=IPV4_ONLY \
  --tags=allow-health-check \
  --image-family=debian-10 \
  --image-project=debian-cloud \
  --metadata=startup-script='#! /bin/bash
    apt-get update
    apt-get install apache2 -y
    a2ensite default-ssl
    a2enmod ssl
    vm_hostname="$(curl -H "Metadata-Flavor:Google" \
    http://metadata.google.internal/computeMetadata/v1/instance/name)"
    echo "VIDEO-HD" | \
    tee /var/www/html/video/hd/index.html
    systemctl restart apache2'

 

When i SSH into my VM instance created using the instance group (based off the above template), i don't see the `/var/www/html/video/hd/index.html` path. I only see `/var/www/html/index/html`

So what am i missing here please?

Solved Solved
0 3 267
1 ACCEPTED SOLUTION

I have been able to access the paths.

I had to update the path in my apache server from `/var/www/html/index.html` to `/var/www/html/video/sd/index.html`.

#! /bin/bash
    apt-get update
    apt-get install apache2 -y
    a2ensite default-ssl
    a2enmod ssl
    sudo mkdir -p /var/www/html/video/sd
    echo "VIDEO-SD" | \
    tee /var/www/html/video/sd/index.html
    systemctl restart apache2

 

View solution in original post

3 REPLIES 3

Can someone please help me with this. Thank you!

Hi @mountaincode2 ,

Welcome to Google Cloud Community!

There are various methods to configure URL rewriting. You can check this tutorial blog for another way of configuring URL rewriting. Another potential cause of the error could be a mismatch in port mapping between the instance group and the load balancer. The port configuration on both the instance group and the load balancer should be the same.

I hope the above information is helpful.

I have been able to access the paths.

I had to update the path in my apache server from `/var/www/html/index.html` to `/var/www/html/video/sd/index.html`.

#! /bin/bash
    apt-get update
    apt-get install apache2 -y
    a2ensite default-ssl
    a2enmod ssl
    sudo mkdir -p /var/www/html/video/sd
    echo "VIDEO-SD" | \
    tee /var/www/html/video/sd/index.html
    systemctl restart apache2