Yandex Cloud
Search
Contact UsTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • AI for business
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Start testing with double trial credits
    • Cloud credits to scale your IT product
    • Gateway to Russia
    • Cloud for Startups
    • Center for Technologies and Society
    • Yandex Cloud Partner program
    • Price calculator
    • Pricing plans
  • Customer Stories
  • Documentation
  • Blog
© 2025 Direct Cursus Technology L.L.C.
Yandex Cloud CDN
  • Getting started
    • All guides
      • Creating a resource
      • Copying configuration from one resource to another
      • Updating basic settings of a resource
      • Getting information about a resource
      • Configuring resource caching
      • Configuring log export
      • Prefetching files to CDN servers
      • Purging resource cache
      • Configuring request and response headers
      • Configuring CORS for responses to clients
      • Configuring HTTP methods
      • Enabling file compression
      • Enabling file segmentation
      • Enabling origin shielding
      • Configuring request redirection
      • Setting up access via a secure token
      • Setting up location rules
      • Managing additional resource settings
      • Disabling a resource
      • Managing resource labels
      • Deleting a resource
      • Viewing resource statistics
  • Access management
  • Pricing policy
  • Terraform reference
  • Monitoring metrics for the EdgeCDN provider
  • Monitoring metrics for the Yandex Cloud CDN provider
  • Request logs
  • Audit Trails events
  • Release notes
  • Troubleshooting
  1. Step-by-step guides
  2. Resources
  3. Configuring request and response headers

Configuring HTTP headers of requests and responses

Written by
Yandex Cloud
Updated at December 3, 2025

Note

The Access-Control-Allow-Origin header for the CORS configuration is configured under CORS when responding to client requests. For more information, see Configuring CORS for responses to clients.

The following restrictions apply to HTTP headers when using the EdgeCDN provider:

  • The HTTP header name may contain Latin letters (A-Z and a-z), numbers (0-9), underscores (_), and hyphens (-).
  • The HTTP header value:
    • Must start with a Latin letter (A-Z or a-z), number (0-9), asterisk (*), or opening curly bracket ({) and may only contain characters with 32 to 126 ASCII codes, except for the backslash (\), dollar sign ($), and single quotation mark (').
    • May not begin or end with a space.
    • May contain Latin letters (A-Z and a-z), numbers (0-9), underscores (_), dots (.), slashes (/), colons (:), hyphens (-), equal signs (=),and spaces ( ).
    • May contain only single spaces between any two characters.
    • May not contain the websocket or upgrade values.
    • May not contain more than 512 characters.

To configure HTTP request and response headers for a resource:

Management console
CLI
Terraform
API
  1. In the management console, select the folder where your resource is located.

  2. Go to Cloud CDN.

  3. Click the resource name.

  4. Navigate to the HTTP headers and methods tab.

  5. In the top-right corner, click Edit.

  6. Under Origin request headers:

    • In the Header field, click Add.
    • Enter names and values of the headers you need.
  7. Under Client response headers:

    • In the Header field, click Add.
    • Enter names and values of the headers you need.
  8. Click Save.

If you do not have the Yandex Cloud CLI installed yet, install and initialize it.

By default, the CLI uses the folder specified when creating the 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 parameter.

  1. View the description of the CLI command to update a resource:

    yc cdn resource update --help
    
  2. Get a list of all resources in the default folder:

    yc cdn resource list --format yaml
    

    Result:

    id: s0me1dkfjq********
    folder_id: s0mef01der7p********
    cname: testexample.com
    created_at: "2022-01-19T09:23:57.921365Z"
    updated_at: "2022-01-19T10:55:30.305141Z"
    active: true
    options:
      edge_cache_settings:
        enabled: true
        default value: "345600"
      cache_http_headers:
        enabled: true
        value:
        - content-type
        - content-length
        - connection
        - server
        - date
        - test
      stale:
        enabled: true
        value:
        - error
        - updating
      allowed_http_methods:
        value:
        - GET
        - POST
        - HEAD
        - OPTIONS
    origin_group_id: "89783"
    origin_group_name: My origins group
    origin_protocol: HTTP
    ssl_certificate:
      type: DONT_USE
      status: READY
    
  3. To add headers, run:

    yc cdn resource update <resource_ID> \
      --static-request-headers <key>=<value> \
      --static-headers <key>=<value>
    

    Where:

    • --static-request-headers: Adds request headers to the origin. You can remove them using the --clear-static-request-headers flag.
    • --static-headers: Adds client response headers. You can remove them using the --clear-static-headers flag.

    For more information about the yc cdn resource update command, see the CLI reference.

If you do not have Terraform yet, install it and configure the Yandex Cloud provider.

  1. In the configuration file, describe the properties of the CDN resource to create:

    terraform {
      required_providers {
        yandex = {
          source  = "yandex-cloud/yandex"
          version = "0.69.0"
        }
      }
    }
    
    provider "yandex" {
      token     = "<OAuth_token>"
      cloud_id  = "<cloud_ID>"
      folder_id = "<folder_ID>"
      zone      = "<availability_zone>"
    }
    
    resource "yandex_cdn_resource" "my_resource" {
        cname               = "cdn1.yandex-example.ru"
        active              = false
        origin_protocol     = "https"
        secondary_hostnames = ["cdn-example-1.yandex.ru", "cdn-example-2.yandex.ru"]
        origin_group_id     = yandex_cdn_origin_group.my_group.id
        options {
          cache_http_headers = ["GET","PUT"]
          cors                 = ["*"]
          static_response_headers = { "world2" = "2hello" }
    
        }
    
    }
    

    Where:

    • cname: Primary domain name used for content distribution. This is a required setting.
    • active: Flag indicating content availability to end users. True: CDN content will be available to clients. This is an optional setting. The default value is true.
    • origin_protocol: Protocol for origins. This is an optional setting. The default value is http.
    • secondary_hostnames: Additional domain names. This is an optional setting.
    • origin_group_id: Origin group ID. This is a required setting. Use the ID from the description of the origin group in the yandex_cdn_origin_group resource.
    • The options section contains additional parameters of CDN resources:
      • static_response_headers: Custom headers that CDN servers send in response to the client. This is an optional setting.

    For more information about the yandex_cdn_resource properties in Terraform, see the provider documentation.

  2. In the command line, go to the directory with the Terraform configuration file.

  3. Check the configuration using this command:

    terraform validate
    

    If the configuration is correct, you will get this message:

    Success! The configuration is valid.
    
  4. Run this command:

    terraform plan
    

    You 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.

  5. Apply the changes:

    terraform apply
    
  6. Type yes and press Enter to confirm the changes.

    You can check the CDN resource update in the management console or using this CLI command:

    yc cdn resource list
    

Use the update REST API method for the Resource resource or the ResourceService/Update gRPC API call.

It may take up to 15 minutes for the new settings of the existing resource to apply to the CDN servers. After that, we recommend purging the resource cache.

See alsoSee also

  • Configuring data exchange between clients and the CDN
  • Configuring data exchange between CDN servers and origins

Was the article helpful?

Previous
Purging resource cache
Next
Configuring CORS for responses to clients
© 2025 Direct Cursus Technology L.L.C.