Connecting a domain
You can connect your own domain to access the API gateway. You can connect a wildcard domain, e.g., *.example.com
, to the API gateway for it to handle requests for all example.com
subdomains. You can also connect multiple domains. The domain will be identified by the Host
header.
Warning
If a third-party DNS provider manages your domain, it must be a third-level domain or lower. For example, you can connect the www.example.com
domain, but not example.com
. This has to do with how CNAME records are processed on DNS hostings. Learn more in RFC 1912, section 2.4
To use the second-level domain, such as example.com
, delegate it to Yandex Cloud DNS and create an ANAME record in the DNS zone.
To connect a domain to an API gateway:
-
Add a CNAME record to your DNS provider or to your own DNS server:
<domain> IN CNAME <API_gateway_service_domain>
To find out an API gateway's service domain:
- Go to the management console
. - Select the folder where the API gateway is located, and in the service list, select API Gateway.
- Select the API gateway.
- You can see the service domain in the Default domain field.
Domain names must end in a dot.
To use a top-level domain or higher, delegate it to Yandex Cloud DNS and create an ANAME record in the DNS zone. You can create a record in Yandex Cloud DNS both before and after creating the domain. For more information, see step 6.
- Go to the management console
-
In the management console
, select the folder containing the API gateway. -
In the list of services, select Certificate Manager and:
-
Add a Let's Encrypt® certificate or a user certificate for the domain you are connecting.
Note
Make sure to timely update your certificates. Learn more about updating Let's Encrypt® certificates and custom certificates.
-
Wait until the certificate status switches to
Issued
.
-
-
Go back to the folder page.
-
In the list of services, select API Gateway and:
- Select the API gateway.
- In the window that opens, go to Domains.
- Click Attach, select a certificate, and enter a domain name (FQDN).
-
If you skipped step 1 and did not add a CNAME record, create an ANAME record in Yandex Cloud DNS:
- Click Create record in the domain row.
- If you do not have a DNS zone with the same name as the domain, create one. To do this, click Create zone.
- Select a different value in the TTL (in seconds) field, if required.
- Click Create.
To add a domain to an API gateway, use the addDomain REST API method for the ApiGateway resource or the ApiGatewayService/AddDomain gRPC API call.