DEV Community

Cover image for Associating a Custom Domain to an API Gateway on Google Cloud
Rodrigo Burgos
Rodrigo Burgos

Posted on

Associating a Custom Domain to an API Gateway on Google Cloud

Setting up a custom domain for your API Gateway on Google Cloud enhances the professional appearance of your APIs and improves brand consistency. Here's a step-by-step guide to achieve this.

Prerequisites

Ensure you have:

  • A domain name managed via Google Cloud DNS or any other DNS provider.
  • An SSL certificate configured in Google Cloud.
  • Steps to Configure API Gateway with a Custom Domain

Steps to Configure API Gateway with a Custom Domain

1 - Create Serverless NEG for API Gateway

gcloud beta compute network-endpoint-groups create api-gateway-serverless-neg --region=us-central1 --network-endpoint-type=serverless --serverless-deployment-platform=apigateway.googleapis.com --serverless-deployment-resource=gateway-name
Enter fullscreen mode Exit fullscreen mode

2 - Attach NEG to Backend Service

gcloud compute backend-services add-backend api-gateway-backend-service --global --network-endpoint-group=api-gateway-serverless-neg --network-endpoint-group-region=us-central1
Enter fullscreen mode Exit fullscreen mode

3 - Create URL Map

gcloud compute target-https-proxies create api-gateway-https-proxy --ssl-certificates=dfb-dev-ssl-cert --url-map=api-gateway-url-map
Enter fullscreen mode Exit fullscreen mode

4 - Create HTTPS Proxy

gcloud compute target-https-proxies create api-gateway-https-proxy --ssl-certificates=dfb-dev-ssl-cert --url-map=api-gateway-url-map
Enter fullscreen mode Exit fullscreen mode

5 - Create Forwarding Rule

gcloud compute forwarding-rules create my-fw --target-https-proxy=api-gateway-https-proxy --global --ports=443
Enter fullscreen mode Exit fullscreen mode

Testing

Verify the custom domain points to the API Gateway:

curl -v https://your-custom-domain.com
Enter fullscreen mode Exit fullscreen mode

Conclusion
By following these steps, you can seamlessly associate a custom domain with your API Gateway, ensuring secure and branded API endpoints.

For more detailed documentation, refer to Google Cloud API Gateway Custom Domains.

Top comments (0)