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
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
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
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
5 - Create Forwarding Rule
gcloud compute forwarding-rules create my-fw --target-https-proxy=api-gateway-https-proxy --global --ports=443
Testing
Verify the custom domain points to the API Gateway:
curl -v https://your-custom-domain.com
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)