Configuring a custom server name for SNI
You can configure a custom server name for SNI (Server Name Indication)
Note
This setting is only available when using an HTTPS connection between the CDN servers and the origin.
Creating a resource with a custom server name for SNI
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id options.
-
View the description of the CLI command to create a resource:
yc cdn resource update --help -
Get a list of all origin groups in the folder:
yc cdn origin-group list --format yamlResult:
- id: "*****" folder_id: b1g86q4m5vej******** name: test-group-1 ... origin_group_id: "*****" source: www.a1.com enabled: true -
Create a resource with a custom server name for SNI:
yc cdn resource create <resource_domain_name> \ --origin-group-id <origin_group_ID> \ --origin-protocol HTTPS \ --custom-server-name <server_name_for_SNI>Result:
id: bc8rpzaciiyp******** folder_id: b1g681qpemb4******** cname: example.com ... custom_server_name: enabled: true value: custom.example.com ...
With Terraform
Terraform is distributed under the Business Source License
For more information about the provider resources, see the relevant documentation on the Terraform
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
-
In the configuration file, describe the properties of the CDN resource to create:
resource "yandex_cdn_resource" "my_resource" { cname = "<domain_name>" active = true origin_protocol = "https" origin_group_id = <origin_group_ID> options { custom_server_name = <server_name_for_SNI> } }Where:
cname: Primary domain name used for content distribution. This is a required setting.active: Flag for content availability to end users, wheretruemeans the CDN content is available to clients, andfalsemeans the content not available. The default value istrue. This is an optional setting.origin_protocol: Protocol for origins. The default value ishttp. This is an optional setting.origin_group_id: Origin group ID. This is a required parameter. Use the ID from the description of the origin group in theyandex_cdn_origin_groupresource.custom_server_name: Custom server name for SNI.
-
Create the resources:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will create all the required resources. You can check the new CDN resource using the management console
or this CLI command:yc cdn resource list -
Add the customServerName section when using the create method for a Resource:
"originProtocol": "HTTPS",
"options": {
"customServerName": {
"enabled": "<true_or_false>",
"value": "string"
}
}
Where:
-
customServerName.enabled: Enabling the option:trueenables the option.falsedisables the option.
-
customServerName.value: Custom server name for SNI. -
originProtocol: Connection protocol between CDN servers and the origin.
Add the custom_server_name section when using the ResourceService/Create call:
"origin_protocol": "HTTPS",
"options": {
"custom_server_name": {
"enabled": "<true_or_false>",
"value": "string"
}
}
Where:
-
custom_server_name.enabled: Enabling the option:trueenables the option.falsedisables the option.
-
custom_server_name.value: New custom server name for SNI. -
origin_protocol: Connection protocol between CDN servers and the origin.
Updating a custom server name for SNI
If you do not have the Yandex Cloud CLI yet, install and initialize it.
The folder used by default is the one specified when creating the CLI profile. To change the default folder, use the yc config set folder-id <folder_ID> command. You can also set a different folder for any specific command using the --folder-name or --folder-id options.
-
View the description of the CLI command to update a resource:
yc cdn resource update --help -
Get a list of all resources in the folder:
yc cdn resource list --format yamlResult:
- id: bc8rpzaciiyp******** folder_id: b1g681qpemb4******** cname: example.com ... custom_server_name: enabled: true value: custom.example.com ... -
Update a custom server name for SNI:
yc cdn resource update <resource_ID> \ --origin-protocol HTTPS \ --custom-server-name <new_server_name_for_SNI>Result:
- id: bc8rpzaciiyp******** folder_id: b1g681qpemb4******** cname: example.com ... custom_server_name: enabled: true value: new.example.com ...To delete a custom server name for SNI, use the
--clear-custom-server-nameflag:yc cdn resource update <resource_ID> \ --clear-custom-server-name
If you do not have Terraform yet, install it and configure the Yandex Cloud provider.
To update the parameters of a CDN resource created using Terraform:
-
Open the Terraform configuration file and edit the fragment with the resource description:
resource "yandex_cdn_resource" "my_resource" { cname = "<domain_name>" active = true origin_protocol = "https" origin_group_id = <origin_group_ID> options { custom_server_name = <new_server_name_for_SNI> } }Where:
cname: Primary domain name used for content distribution. This is a required setting.active: Flag for content availability to end users, wheretruemeans the CDN content is available to clients, andfalsemeans the content not available. The default value istrue. This is an optional setting.origin_protocol: Protocol for origins. The default value ishttp. This is an optional setting.origin_group_id: Origin group ID. This is a required parameter. Use the ID from the description of the origin group in theyandex_cdn_origin_groupresource.custom_server_name: New custom server name for SNI.
-
Apply the changes:
-
In the terminal, go to the directory where you edited the configuration file.
-
Make sure the configuration file is correct using this command:
terraform validateIf the configuration is correct, you will get this message:
Success! The configuration is valid. -
Run this command:
terraform planYou will see a detailed list of resources. No changes will be made at this step. If the configuration contains any errors, Terraform will show them.
-
Apply the changes:
terraform apply -
Type
yesand press Enter to confirm the changes.
Terraform will update all the required resources. You can check the CDN resource update in the management console
or using this CLI command:yc cdn resource list -
Add the customServerName section when using the update method for a Resource:
"originProtocol": "HTTPS",
"options": {
"customServerName": {
"enabled": "<true_or_false>",
"value": "string"
}
}
Where:
-
customServerName.enabled: Enabling the option:trueenables the option.falsedisables the option.
-
customServerName.value: Custom server name for SNI. -
originProtocol: Connection protocol between CDN servers and the origin.
Add the custom_server_name section when using the ResourceService/Update call:
"origin_protocol": "HTTPS",
"options": {
"custom_server_name": {
"enabled": "<true_or_false>",
"value": "string"
}
}
Where:
-
custom_server_name.enabled: Enabling the option:trueenables the option.falsedisables the option.
-
custom_server_name.value: New custom server name for SNI. -
origin_protocol: Connection protocol between CDN servers and the origin.