Implement Regional Internal Proxy NLB - GSP636

A passionate full-stack developer from @ePlus.DEV
Overview
A regional internal proxy Network Load Balancer is used when you need to load balance internal traffic (from within your VPC or connected networks) and your application requires Layer 4 proxy-based control, like TLS/SSL termination (unavailable in the Passthrough model).
This load balancer is the optimal solution for managing robust, scalable internal services.
Internal Access Only: The key constraint is that the service is exposed via an internal IP address only accessible to clients inside your private network or private connections (VPN, Interconnect).
Proxy-Based Stability: This is a full proxy. The load balancer terminates the client connection and establishes a new one to the backend. This allows for superior session management, health monitoring, and connection draining.
Layer 4 TLS Termination: The proxy function allows you to implement TLS/SSL termination at the load balancer level for internal traffic, securing service-to-service communication without placing the decryption burden on the backends.
Global Access (Optional): While regional by default, this NLB supports global access, allowing clients in other regions of your VPC to reach the internal IP, which is a significant feature for distributed applications (out of scope for this lab).
In this lab you will configure a custom VPC network and a proxy-only subnet, set ingress firewall rules, and deploy a Regional Internal Proxy Network Load Balancer with specific port mapping to ensure backend health and validate internal traffic distribution using a client VM.
There is an optional task at the end of the lab to practice the skills you've learned.
What you'll learn or Objectives
Configure a custom VPC network with the required
proxy-onlysubnet and establish a proxy security policy with VPC ingress firewall rules.Configure port mapping.
Deploy the Regional Internal Proxy Network Load Balancer.
Deploy and utilize an internal client VM within the same VPC network and test traffic distribution.
Setup and requirements
Before you click the Start Lab button
Read these instructions. Labs are timed and you cannot pause them. The timer, which starts when you click Start Lab, shows how long Google Cloud resources are made available to you.
This hands-on lab lets you do the lab activities in a real cloud environment, not in a simulation or demo environment. It does so by giving you new, temporary credentials you use to sign in and access Google Cloud for the duration of the lab.
To complete this lab, you need:
- Access to a standard internet browser (Chrome browser recommended).
Note: Use an Incognito (recommended) or private browser window to run this lab. This prevents conflicts between your personal account and the student account, which may cause extra charges incurred to your personal account.
- Time to complete the lab—remember, once you start, you cannot pause a lab.
Note: Use only the student account for this lab. If you use a different Google Cloud account, you may incur charges to that account.
How to start your lab and sign in to the Google Cloud console
Click the Start Lab button. If you need to pay for the lab, a dialog opens for you to select your payment method. On the right is the Lab setup and access panel with the following:
The Open Google Cloud console button
The temporary credentials (username and password) that you must use for this lab
Other information, if needed, to step through this lab
Note that the lab timer is located near the top of the page, showing the remaining time.
Click Open Google Cloud console (or right-click and select Open Link in Incognito Window if you are running the Chrome browser).
The lab spins up resources, and then opens another tab that shows the Sign in page.
Tip: Arrange the tabs in separate windows, side-by-side.
Note: If you see the Choose an account dialog, click Use Another Account.
If necessary, copy the Username below and paste it into the Sign in dialog.
student-04-5f4b6d5465b8@qwiklabs.netYou can also find the Username in the Lab setup and access panel.
Click Next.
Copy the Password below and paste it into the Welcome dialog.
IBuRl9jHUyCjYou can also find the Password in the Lab setup and access panel.
Click Next.
Important: You must use the credentials the lab provides you. Do not use your Google Cloud account credentials.
Note: Using your own Google Cloud account for this lab may incur extra charges.
Click through the subsequent pages:
Accept the terms and conditions.
Do not add recovery options or two-factor authentication (because this is a temporary account).
Do not sign up for free trials.
After a few moments, the Google Cloud console opens in this tab.
Note: To access Google Cloud products and services, click the Navigation menu or type the service or product name in the Search field.
Task 1. Configure the Network and Subnets
In this task you are building the foundation. The internal proxy NLB model introduces a critical networking requirement: the proxy-only subnet. This reserved, dedicated subnet range is where Google Cloud provisions the Envoy proxies that run the load balancing service.
You must first create a custom VPC network with 2 required subnets: one for your backends (backend-subnet) and the essential one for the proxy control plane (proxy-only-subnet).
Deployment Parameters
Network: lb-network (Custom Mode)
Backend Subnet
us-east1: 10.1.2.0/24Proxy-Only Subnet
us-east1: 10.129.0.0/23
Create the network and backends/test subnets
In the Google Cloud console, navigate to the VPC network page. You can use the search bar at the top of the page, or the menu button in the top left corner.
Click Create VPC network.
For Name, enter
lb-network.Set the Subnet creation mode to
Custom.Under New subnet, specify the following properties to create the subnets.
Create the Backend Subnet:
Property Value Name backend-subnet Region us-east1IPv4 range 10.1.2.0/24 Click Done.
Create the Proxy-Only Subnet
This subnet is exclusively for Google-managed Envoy proxies. You cannot assign backends or forwarding rule IPs from this range.
In the console, go to the VPC networks page and click the lb-network name.
Click on the Subnets tab along the top. Click Add subnet.
Property Value Name proxy-only-subnet Region us-east1Purpose Regional Managed Proxy IPv4 range 10.129.0.0/23 Click Add.
Click Check my progress to verify the objective.
Create the network and backends/test subnets
Task 2. Create Firewall Rules
In this task you're defining the security matrix. Since the load balancer is a proxy, traffic to the backends comes from two specific sources: Google's Health Check IP ranges (for probes) and the IP range of the Proxy-Only Subnet (for forwarded client traffic). You must explicitly create three ingress rules to allow this traffic, otherwise the default firewall rule will block your service.
In the console, navigate to Navigation menu > VPC network > Firewall.
Click Create Firewall Rule.
Set the following values, leave all other values at their defaults:
Property Value (type value or select option as specified) Name fw-allow-ssh Target tags allow-ssh Source filter IPv4 Ranges Source IP ranges 0.0.0.0/0 Protocols and ports Specified protocols and ports, and then check tcp, type: 22 Click Create.
Create another firewall rule named
fw-allow-health-checkSet the following values, leave all other values at their defaults:
Property Value (type value or select option as specified) Name fw-allow-health-check Target tags allow-health-check Source filter IPv4 Ranges Source IP ranges 130.211.0.0/22, 35.191.0.0/16 Protocols and ports Specified protocols and ports, and then check tcp, type: 80 Click Create.
Create another firewall rule named
fw-allow-proxy-only-subnetand set the following values:Property Value (type value or select option as specified) Name fw-allow-proxy-only-subnet Target tags allow-proxy-only-subnet Source filter IPv4 Ranges Source IP ranges 10.129.0.0/23 Protocols and ports Specified protocols and ports, and then check tcp, type: 80 Click Create.
Click Check my progress to verify the objective.
Create Firewall Rules
Task 3. Create backend Managed Instance Groups (MIGs)
Your backends are hosted on two Managed Instance Groups (MIGs) across two different zones in us-east1. This ensures zonal redundancy and enables autoscaling (though autoscaling is off for this lab). Since this is a proxy NLB, the load balancer will connect to the backends on a named port (e.g., tcp80) which is mapped to the internal TCP port (80) where the Apache server is listening.
Create an Instance Template
In the GCP Console, on the Navigation menu, click Compute Engine > Instance templates page.
Click Create instance template.
For Name, enter
int-tcp-proxy-backend-template.Click Advanced options > Networking.
For Network tags, enter the three required tags:
allow-ssh,allow-health-check, andallow-proxy-only-subnet.For Network interfaces, select Network:
lb-networkand Subnet:backend-subnetand click Done.
Click Management. Paste the following script to install and configure Apache to listen on port 80 and report its hostname:
#! /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 "Page served from: $vm_hostname" | \
tee /var/www/html/index.html
systemctl restart apache2
- Click Create.
Create the MIGs
Navigate to the Instance groups page.
Click Create instance group > New managed instance group (stateless).
Property Value Name mig-a Instance template int-tcp-proxy-backend-template Region us-east1Zone us-east1-cAutoscaling mode Off: do not autoscale (Max instances: 2) Port mapping Add port name tcp80mapped to port number80Click Create.
Repeat the process to create mig-c in a different zone from the instance group above.
Keep all other settings the same.
Click Check my progress to verify the objective.
Create backend Managed Instance Groups (MIGs)
Verify backend service binding
Wait 3-5 minutes for the MIG instances to finish starting and the startup script to complete.
Run the following command to check if the Apache service is listening on port 80 on one of the instances.
gcloud compute instances list --filter="name ~ mig-a" --limit=1 --format='value(name)'SSH to the instance and run a network status check:
gcloud compute ssh $(gcloud compute instances list --filter="name ~ mig-a" --limit=1 --format='value(name)') --zone=us-east1-c --command="sudo netstat -tnlp | grep 80"Expected output: The output should show a process (Apache2) listening on
0.0.0.0:80or:::80. If it shows127.0.0.1:80, the startup script failed to bind to all interfaces, and the lab will fail later.
Task 4. Configure the Load Balancer (internal IP and proxy rules)
Now you will define the health check, the backend service (which consumes the MIGs), and the frontend (which exposes the internal IP on the service port 110). The port mapping (tcp80 to 80) ensures the NLB uses the correct port to connect to the backends, while the frontend port (110) is what clients use to connect to the proxy.
Open Cloud Shell, then run the following
gcloudcommands to reserve a static internal IPv4 address inus-east1on thebackend-subnet.
```
gcloud compute addresses create int-tcp-ip-address
--region=us-east1
--subnet=backend-subnet
--purpose=SHARED_LOADBALANCER_VIP
```Use the following command to retrieve and record the actual IP address, which you will use as your LB_IP_ADDRESS:
```
gcloud compute addresses describe int-tcp-ip-address
--region=us-east1
--format='value(address)'
```he output of this command is your
LB_IP_Address. Make a note of it, you will need it later in this lab.In the console, type Load Balancing in the search bar at the top. Under Products & Pages, click on Load balancing
on the Network Services > Load balancing page, click + Create load balancer.
Select Network Load Balancer (TCP/UDP/SSL) and Next.
Select Proxy load balancer and Next
Select Internal and Next
Select Best for regional workloads and Next.
Select Configure.
Name the load balancer as
my-int-tcp-lb, region asus-east1and select Network aslb-networkChoose Backend Configuration:
Property Value Protocol Select TCPNamed Port Enter tcp80Under Health check, click Create a health check
Property Value Name tcp-health-check Protocol Select TCPPort Enter 80Click Create.
Set the following values for the backend:
Instance group: From the dropdown, select the instance group
mig-a.Port numbers: Enter
80
Click Done.
Click Add a backend.
Repeat the same for
mig-cwith port number80Click on Frontend configuration and set the following values:
Property Value Name int-tcp-forwarding-rule Subnetwork From the dropdown, select the backend-subnetIP address Select the reserved internal IP address for the load balancer Port 110 Proxy Protocol Off Click Review and finalize then Create and wait for the load balancer to be created.
Click Check my progress to verify the objective.
Configure the Load Balancer
Task 5. Test the load balancer
Since this is an internal load balancer, you cannot test it from the internet. You must first provision a client VM within the VPC network. You will then use curl to connect from this internal client to the load balancer's internal IP on the service port (110) to validate traffic distribution.
Create a Client VM
In the Console, go to Compute Engine > VM Instances. Click the Create Instance button.
Set the following values, leave all other values at their defaults:
Property Value Name client-vm Zone us-east1-cNetwork tags allow-ssh Network interface Click Add a network interfaces and select Network as lb-networkand Subnet asbackend-subnetClick Create.
Verify backend health
Before proceeding with the curl test, wait 5-10 minutes for the MIGs to finish provisioning and for the health check probes to start and mark the backends as healthy. If the backends aren't ready, you may see an error like this: curl: (56) Recv failure: Connection reset by peer error which means that the backends are Unhealthy and the load balancer has nowhere to send the traffic.
To verify the health status, run the following in Cloud Shell:
gcloud compute backend-services get-health my-int-tcp-lb --region=us-east1
You should see an output similar to the following, showing both Instance Groups (mig-a and mig-c) are in a HEALTHY state:
healthStatus:
- healthState: HEALTHY
instanceGroup: projects/YOUR_PROJECT/regions/REGION/instanceGroups/mig-a
- healthState: HEALTHY
instanceGroup: projects/YOUR_PROJECT/regions/REGION/instanceGroups/mig-c
If the status is UNHEALTHY or UNKNOWN: do not proceed. Re-verify that the firewall rule fw-allow-health-check is correctly configured to allow traffic from 130.211.0.0/22, 35.191.0.0/16 to port 80 on instances with the tag allow-health-check. Wait a few more minutes and re-run the get-health command.
Send traffic and verify distribution
Once you've confirmed that the backends are healty, send some traffic to confirm it is getting distributed to both backends.
Use SSH to connect to the client VM:
gcloud compute ssh client-vm --zone=us-east1-cWhen prompted, enter
Yto confirm creating a new directory.When prompted for a passphrase, press Enter for no passphrase, and then again to confirm.
Confirm that the TCP connection can be established to the frontend port (
110):telnet <lb_ip_address> 110 </lb_ip_address>The connection should be established immediately (Connected to <LB_IP_ADDRESS>). If it hangs or shows a "Connection refused" or "Connection timed out" error, check the fw-allow-proxy-only-subnet firewall rule in Task 2 to ensure the client-vm (which is in backend-subnet: 10.1.2.0/24) is allowed to talk to the LB VIP.
Now run the curl command to send traffic to the load balancer's reserved internal IP. Replace <LB_IP_ADDRESS> with the IP address you noted earlier:
curl <lb_ip_address>:110 </lb_ip_address>You should see a response showing the hostname of one of your backend instances (mig-a-XXXX or mig-c-XXXX).
Run the command repeatedly. You should see the hostname alternate, confirming that the regional internal proxy Network Load Balancer is successfully distributing internal client traffic across your zonal backend MIGs
Optional) Task 6. Practice your skills
In this optional task, you refactor the VM deployment to use distinct instance templates. This enforces the principle of least privilege by ensuring the client VM does not have unnecessary backend-specific network tags.
Create the client instance template
Create a new instance template named int-tcp-proxy-client-template.
For the Network Interface, select lb-network and backend-subnet.
For the Network Tag, add allow-ssh and ensure it is the only tag.
Refactor the client VM creation
Return to the steps in Task 5.
Delete the existing client-vm instance.
Re-create the client-vm using the new int-tcp-proxy-client-template.
Verify the backend template
Return to the steps in Task 3.
Review the int-tcp-proxy-backend-template.
Ensure it contains only the tags required for the backends: allow-ssh, allow-health-check, and allow-proxy-only-subnet.
Verify functionality
Return to the steps in Task 5.
From the new client-vm, re-run the
curltest to ensure functionality is unchanged.
Solution of Lab
Quick
https://www.youtube.com/watch?v=PMYDaM749wc
curl -LO raw.githubusercontent.com/ePlus-DEV/storage/refs/heads/main/labs/GSP636/lab.sh
source lab.sh
Script Alternative
wget -O SakshamXTech.sh "https://raw.githubusercontent.com/Saksham-Dev-001/Arcade-Google-Cloud-Labs/refs/heads/main/Implement%20Regional%20Internal%20Proxy%20NLB/SakshamXTech.sh"
sed -i 's/\r$//' SakshamXTech.sh
chmod +x SakshamXTech.sh
bash SakshamXTech.sh
Task 5 error:
Try script:
gcloud compute instances create client-vm \
--zone=us-east1-d \
--machine-type=e2-micro \
--network=lb-network \
--subnet=backend-subnet \
--tags=allow-ssh \
--quiet




