Google cloud load balancer redirect www to naked domain

9/2/2018

I'm using Google Cloud Load Balancer as the ingress controller to my GCP Kubernetes application. I want all requests to www.my_domain.com to be redirected to my_domain_.com.

Note: My GCLB is configured with an SSL certificate that is valid for both www.my_domain.com and my_domain.com.

I know this is possible using an http redirect in my external DNS management console, but an issue arises because of SSL termination.

  1. I create an http redirect rule in my DNS management console to route all www.my_domain.com traffic to https://my_domain.com.

  2. If a client browses to domain https://www.my_domain.com, they will get a browser warning because the request will first go to server of my DNS management tool, which is not configured with a matching SSL cert.

I know that GCLB has limitations for redirecting http traffic to https, but that's not my main concern here. What I want to know is if it's possible in GCLB to configure a routing rule so that any request for www.my_domain.com is redirected to my_domain.com.

Thanks for any help!

-- Murcielago
dns
google-cloud-platform
kubernetes
kubernetes-ingress

1 Answer

9/3/2018

Unfortunately, there is no such functionality in GCLB.

In this case, you should use custom (for example nginx) ingress controller.

You can find here and here how to setup nginx controller for Kubernetes.

-- Akar
Source: StackOverflow