Blog

Bereitstellen eines HTTPS-Load-Balancers mit einem von Google verwalteten Wildcard-SSL-Zertifikat auf Google Cloud Platform

Daan Heikens

Aktualisiert Oktober 15, 2025
6 Minuten

Kürzlich habe ich mich gefragt, ob ich ein von Google verwaltetes Wildcard SSL-Zertifikat auf meinem Global External HTTPS Load Balancer einsetzen kann. In diesem Blog zeige ich Ihnen Schritt für Schritt, wie Sie einen Global HTTPS Load Balancer mit einem von Google verwalteten Wildcard SSL-Zertifikat einrichten können.

Hintergrundforschung

Von Google verwaltete SSL-Zertifikate für Cloud Load Balancing unterstützen laut dieser Dokumentation standardmäßig keine Platzhalter-Common-Names bei der Bereitstellung von Load Balancern. Bei einer schnellen Suche in der Google Cloud Platform-Dokumentation wurde ich jedoch auf den Dienst Certificate Manager verwiesen. Es scheint, dass der Certificate Manager Service Wildcard Common Names unterstützt. Wie können wir also Zertifikate aus dem Certificate Manager mit einem globalen externen HTTPS-Load Balancer verbinden?

Kompatibilität

Zunächst wollte ich prüfen, ob es eine native Integration zwischen Cloud Load Balancing und dem Certificate Manager gibt. Ich habe einen interessanten Vergleich zwischen Zertifikaten und Google Cloud Load Balancern gefunden. Der Vergleich zeigt, welche Load Balancer mit dem Certificate Manager kompatibel sind, und wie der Zufall es will, ist der Global External HTTPS Load Balancer kompatibel!

Domain-Autorisierung

Der nächste Schritt bestand darin, herauszufinden, welche Methode der Domänenautorisierung Wildcard Common Names unterstützt. Der Certificate Manager erfordert die Konfiguration der Domain-Autorisierung für von Google verwaltete SSL-Zertifikate, um den Besitz der Domain(s) des SSL-Zertifikats nachzuweisen. Google Cloud Platform bietet dazu zwei Optionen:

  1. Load Balancer-Autorisierung
  2. DNS-Autorisierung

Load Balancer Autorisierung

Die Load Balancer-Autorisierung ist ein grundlegenderer Ansatz, der keine zusätzlichen DNS-Änderungen erfordert und daher schneller zu konfigurieren ist. Die angehängte Load Balancer-Autorisierung unterstützt jedoch keine Wildcard Common Names.

DNS-Autorisierung

Die DNS-Autorisierung erfordert eine zusätzliche DNS-Konfiguration durch Hinzufügen von DNS-Einträgen zum Nachweis der Eigentümerschaft unter Verwendung von Cloud DNS oder einer DNS-Lösung eines Drittanbieters. Die DNS-Autorisierung unterstützt Wildcard Common Names. Daher ist dies der einzige praktikable Weg für die Implementierung.

Bereitstellung des globalen HTTPS-Load-Balancers

Wichtig: Stellen Sie sicher, dass Sie Ihre Cloud-Domain konfiguriert haben und den Cloud-DNS-Anbieter verwenden, wenn Sie diese Beispiele verwenden.

In unseren Beispielen für die Bereitstellung werden wir Terraform verwenden, da es als Best Practice gilt, Infrastructure as Code (IaC) anzustreben, wo immer dies möglich ist.

Um einen Global Load Balancer mit einem von Google verwalteten Wildcard-SSL-Zertifikat einzusetzen, werden 3 Hauptkomponenten konfiguriert:

  1. Cloud DNS
  2. Zertifikat Manager
  3. Globaler HTTPS-Lastausgleicher

Öffentliche DNS-Zone in Cloud DNS erstellen

Bevor Sie den Load Balancer erstellen, erstellen Sie zunächst eine öffentliche DNS-Zone in Cloud DNS.

## Enable the Cloud DNS API ##
resource "google_project_service" "cloud_dns" {
  service = "dns.googleapis.com"
}

## Public Cloud DNS zone. Make sure to configure your domain under Google Domains to use Cloud DNS ##
resource "google_dns_managed_zone" "public_dns_zone" {
  name        = "public-dns-zone"
  dns_name    = "example.com."
  description = "Public DNS zone for example.com"

  lifecycle {
    prevent_destroy = true
  }
}

Als Nächstes konfigurieren Sie den Zertifikatsmanager mit DNS-Autorisierung und Platzhalter-Common-Namen.

## Certificate manager resources to provision a wildcard SSL certificate for a Load Balancer. Requires a Public DNS zone ##

## Enable the certificate manager API ##
resource "google_project_service" "certificate_manager" {
  service = "certificatemanager.googleapis.com"
}

## Configure DNS authorization to provide the ACME challenge DNS records ##
resource "google_certificate_manager_dns_authorization" "dns_authorization" {
  name        = "dns-authorization"
  description = "DNS authorization for example.com to support wildcard certificates"
  domain      = "example.com"
}

## Provision a wildcard managed SSL certificate using DNS authorization ##
resource "google_certificate_manager_certificate" "wildcard_ssl_certificate" {
  name        = "wildcard-ssl-certificate"
  description = "Wildcard certificate for ${local.fqdn} and sub-domains"

  managed {
    domains = ["example.com", "*.example.com"]
    dns_authorizations = [
      google_certificate_manager_dns_authorization.dns_authorization.id
    ]
  }
}

## Certificate map resource to reference to from a forwarding rule ##
resource "google_certificate_manager_certificate_map" "certificate_map" {
  name        = "certificate-map"
  description = "${local.fqdn} certificate map containing the domain names and sub-domains names for the SSL certificate"
}

## Certificate map entry for the top-level domain ##
resource "google_certificate_manager_certificate_map_entry" "domain_certificate_entry" {
  name         = "domain-cert-entry"
  description  = "example.com certificate entry"
  map          = google_certificate_manager_certificate_map.certificate_map.name
  certificates = [google_certificate_manager_certificate.wildcard_ssl_certificate.id]
  hostname     = "example.com"
}

## Certificate map entry for the sub domain
resource "google_certificate_manager_certificate_map_entry" "sub_domain_certificate_entry" {
  name         = "sub-domain-entry"
  description  = "*.example.com certificate entry"
  map          = google_certificate_manager_certificate_map.certificate_map.name
  certificates = [google_certificate_manager_certificate.wildcard_ssl_certificate.id]
  hostname     = "*.example.com"
}

Die Ressource google_certificate_manager_dns_authorization gibt die erforderlichen DNS-Informationen aus, um die Einrichtung der DNS-Autorisierung abzuschließen, die der zuvor erstellten DNS-Zone hinzugefügt werden muss. Fügen Sie den folgenden DNS-Eintrag hinzu:

## DNS authorization record ##
resource "google_dns_record_set" "dns_authorization_wildcard_certificate" {
  name         = google_certificate_manager_dns_authorization.dns_authorization.dns_resource_record[0].name
  managed_zone = google_dns_managed_zone.public_dns_zone.name
  type         = google_certificate_manager_dns_authorization.dns_authorization.dns_resource_record[0].type
  ttl          = 300
  rrdatas      = [google_certificate_manager_dns_authorization.dns_authorization.dns_resource_record[0].data]
}

Externe IP-Adresse konfigurieren

Um eine reibungslose Einrichtung des Load Balancer zu ermöglichen, konfigurieren wir eine externe IP-Adresse für den Global HTTPS Load Balancer

# Load balancer IP
resource "google_compute_global_address" "lb_ip_address" {
  name        = "example-lb-ip"
  description = "Public IP address of the Global HTTPS load balancer"
}

DNS-Zone mit entsprechenden Einträgen aktualisieren

Hinzufügen von DNS-Einträgen für Domänennamen und Wildcard-Subdomänen zur DNS-Zone

## Global load balancer DNS records ##
resource "google_dns_record_set" "global_load_balancer_sub_domain" {
  managed_zone = google_dns_managed_zone.public_dns_zone.name
  name         = "*.${google_dns_managed_zone.public_dns_zone.dns_name}"
  type         = "A"
  rrdatas      = [google_compute_global_address.lb_ip_address.address]
}

resource "google_dns_record_set" "global_load_balancer_top_level_domain" {
  managed_zone = google_dns_managed_zone.public_dns_zone.name
  name         = google_dns_managed_zone.public_dns_zone.dns_name
  type         = "A"
  rrdatas      = [google_compute_global_address.lb_ip_address.address]
}

Load Balancer-Ressourcen erstellen


# HTTPS load balancer
resource "google_compute_global_forwarding_rule" "https_forwarding_rule" {
  name        = "https-forwarding-rule"
  description = "Global external load balancer"
  ip_address  = google_compute_global_address.lb_ip_address.id
  port_range  = "443"
  target      = google_compute_target_https_proxy.https_proxy.self_link
}

# HTTPS proxy
resource "google_compute_target_https_proxy" "https_proxy" {
  name            = "https-webserver-proxy"
  description     = "HTTPS Proxy mapping for the Load balancer including wildcard ssl certificate"
  url_map         = google_compute_url_map.url_map.self_link
  certificate_map = "//${google_project_service.certificate_manager.service}/${google_certificate_manager_certificate_map.certificate_map.id}"
}

# HTTP proxy
resource "google_compute_global_forwarding_rule" "http_forwarding_rule" {
  name        = "http-forwarding-rule"
  description = "Global external load balancer HTTP redirect"
  ip_address  = google_compute_global_address.lb_ip_address.id
  port_range  = "80"
  target      = google_compute_target_http_proxy.http_proxy.self_link
}

## HTTPS redirect proxy
resource "google_compute_target_http_proxy" "http_proxy" {
  name        = "http-webserver-proxy"
  description = "Redirect proxy mapping for the Load balancer"
  url_map     = google_compute_url_map.http_https_redirect.self_link
}

# Default URL map
resource "google_compute_url_map" "url_map" {
  name        = "url-map"
  description = "Url mapping to the backend services"
}

# Redirect URL map
resource "google_compute_url_map" "http_https_redirect" {
  name        = "http-https-redirect"
  description = "HTTP Redirect map"

  default_url_redirect {
    https_redirect         = true
    redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
    strip_query            = false
  }
}

Mit dem Argument certificates_map können wir auf die zuvor erstellte Zertifikatskarte verweisen und das Wildcard-SSL-Zertifikat verwenden.

Überlegungen zur Sicherheit

Die Verwendung eines Wildcard-SSL-Zertifikats bedeutet, dass Ihre Top-Level-Domain und alle Ihre Sub-Domains dasselbe SSL-Zertifikat verwenden würden. Das heißt, wenn ein von Google verwaltetes SSL-Zertifikat kompromittiert wird, wirkt sich dies auf alle HTTPS-Anwendungen aus, die sich hinter dem Global External HTTPS Load Balancer befinden, der dieses Zertifikat verwendet. Sie sollten immer abwägen, ob ein Wildcard-SSL-Zertifikat zu Ihrer Risikobereitschaft passt.

Fazit

Das Anhängen eines von Google verwalteten Wildcard-SSL-Zertifikats an einen Global External HTTPS Load Balancer ist möglich, wenn Sie den Certificate Manager Service und Cloud DNS mit DNS-Autorisierung verwenden. Dieser Ansatz bietet einen wartbaren und Cloud-nativen Ansatz, der die zusätzliche Konfiguration von Zertifikaten für Subdomänen, die an einen Global External HTTPS Load Balancer angeschlossen sind, überflüssig macht.


Foto von Parsoa Khorsand von Unsplash

Verfasst von

Daan Heikens

I work as a Google Cloud Consultant at Xebia. Working as a consultant, I help clients design and implement secure cloud architectures. I am passionate about technology, craft beers and Formula 1. A curious, enthusiastic and a constant tinkerer. I’m eager to learn new things and have a passion for cloud native security.​ You’ll find me listening to podcasts, reading books and blogs in my spare time.

Contact

Let’s discuss how we can support your journey.