I create a group with 6 instances on GCP and use the GCP load balancer(LB). I use nginx with Let's encrypt, and all websites have to use https.
My condition as shown below.
server 1 : x11.abc.com
(LB dns: x1.abc.com
), x31.abc.net
(LB dns: x3.abc.net
)
server 2 : x12.abc.com
(LB dns: x1.abc.com
), x32.abc.net
(LB dns: x3.abc.net
)
server 3 : x13.abc.com
(LB dns: x1.abc.com
), x33.abc.net
(LB dns: x3.abc.net
)
server 4 : x21.abc.com
(LB dns: x2.abc.com
), x34.abc.net
(LB dns: x3.abc.net
)
server 5 : x22.abc.com
(LB dns: x2.abc.com
), x35.abc.net
(LB dns: x3.abc.net
)
server 6 : x23.abc.com
(LB dns: x2.abc.com
), x36.abc.net
(LB dns: x3.abc.net
)
But when I test, x1.abc.com
shows the contents of x11 ~ x13 and x21 ~ x23, and x3.abc.net
shows the content of x31 ~ x36, BUT x2.abc.com
shows the request url was not found.
I want to x1.abc.com shows the contents of x11 ~ x13, x2.abc.com shows the contents of x21 ~ x23, and x3.abc.net shows the contents of x31 ~ x36.
How do I setup the GCP load balancer?
The following suggestions you can follow to setup the load balancer:
This is one way to create an HTTP(S) load balancer that distributes traffic to different instances based on the path in the request URL (check configure host and path rule section ).