Yandex Cloud
Search
Discuss with expertTry it for free
  • Customer Stories
  • Documentation
  • Blog
  • All Services
    • Cloud Interconnect
    • Cloud Backup
    • Cloud Registry
    • Yandex AI Studio
    • Compute Cloud
    • Object Storage
    • Managed Service for Kubernetes®
    • Yandex BareMetal
    • Smart Web Security
    • Security Deck
    • Managed Service for PostgreSQL
    • Managed Service for ClickHouse®
    • Monium
    • Cloud CDN
    • Network Load Balancer
    • Virtual Private Cloud
    • Cloud DNS
    • Application Load Balancer
    • Yandex Cloud Video
    • Stackland
    • Yandex Cloud Router
    • Yandex Managed Service for Trino
    • Managed Service for MySQL®
    • Managed Service for Valkey™
    • Managed Service for Apache Spark™
    • Yandex StoreDoc
    • Managed Service for OpenSearch
    • Managed Service for Apache Kafka®
    • Data Transfer
    • Yandex MPP Analytics Engine for PostgreSQL
    • Yandex Managed Service for Apache Airflow®
    • Data Processing
    • Yandex MetaData Hub
    • Managed Service for YDB
    • Managed Service for Sharded PostgreSQL
    • Managed Service for YTsaurus
    • Yandex WebSQL
    • DataLens
    • Yandex Search API
    • SpeechSense
    • SpeechKit
    • DataSphere
    • Vision OCR
    • Translate
    • Yandex Identity Hub
    • Key Management Service
    • Certificate Manager
    • Yandex Lockbox
    • Audit Trails
    • SmartCaptcha
    • Cloud Desktop
    • SourceCraft Code Assistant
    • Container Registry
    • Managed Service for GitLab
    • Managed Service for Prometheus®
    • Cloud Functions
    • API Gateway
    • Yandex Cloud Postbox
    • Message Queue
    • Serverless Integrations
    • IoT Core
    • Data Streams
    • Serverless Containers
    • Cloud Notification Service
    • Yandex Query
    • Identity and Access Management
    • Yandex Cloud Console
    • Resource Manager
    • Yandex Cloud Billing
    • Yandex Cloud Quota Manager
    • Cloud Apps
  • System Status
  • Marketplace
    • Featured
    • Infrastructure & Network
    • Data Platform
    • AI for business
    • Security
    • DevOps tools
    • Serverless
    • Monitoring & Resources
  • 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
© 2026 Direct Cursus Technology L.L.C.
Yandex Cloud CDN
    • 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 the CDN server cache
      • Purging resource cache
      • Configuring request and response headers
      • Configuring CORS for responses to clients
      • Configuring HTTP methods
      • Setting up an HTTP response
      • Enabling file compression
      • Enabling file segmentation
      • Enabling origin shielding
      • Setting up a request redirect
      • Enabling a resource to follow request redirects
      • Setting up hiding of origin headers
      • Setting up access via a secure token
      • Setting up location rules
      • Setting up a server name for SNI
      • Suspending and resuming a resource
      • Managing resource labels
      • Configuring dedicated IP addressing
      • Configuring a TLS profile
      • Deleting a resource
      • Viewing resource statistics
  • Access management
  • Pricing policy
  • Terraform reference
  • Metrics Monitoring
  • Request logs
  • Audit Trails events
  • Release notes
  • Troubleshooting
  1. Step-by-step guides
  2. Resources
  3. Enabling a resource to follow request redirects

Setting up how to follow request redirects

Written by
Yandex Cloud
Updated at June 30, 2026
View in Markdown

You can deactivate request redirects via the API when creating or updating a CDN resource.

Note

The option works only if the origin shielding function is on.

REST API
gRPC API

To enable the option, add the followRedirects section when using the create or update method for a Resource:

"followRedirects": {
  "enabled": "<true_or_false>",
  "codes": [
    "<list_of_codes>"
  ],
  "useCustomHost": "<true_or_false>"
}

Where:

  • enabled: Enabling the option:

    • true enables the option.
    • false disables the option.
  • codes: List of redirect codes Cloud CDN will follow. The possible values are:

    • 301: Moved Permanently.
    • 302: Found.
    • 303: See Other.
    • 307: Temporary Redirect.
    • 308: Permanent Redirect.
  • useCustomHost: Managing the Host header:

    • true: Using the Host header from the primary origin. For example, if the example.com origin returns a redirect to ya.ru, the request will be sent with Host: example.com.
    • false: Using the Host header from the redirect domain. For example, if the example.com origin returns a redirect to ya.ru, the request will be sent with Host: ya.ru.

To enable the option, add the follow_redirects section when using the ResourceService/Create or ResourceService/Update call:

"follow_redirects": {
  "enabled": "<true_or_false>",
  "codes": [
    "<list_of_codes>"
  ],
  "use_custom_host": "<true_or_false>"
}

Where:

  • enabled: Enabling the option:

    • true enables the option.
    • false disables the option.
  • codes: List of redirect codes Cloud CDN will follow. The possible values are:

    • 301: Moved Permanently.
    • 302: Found.
    • 303: See Other.
    • 307: Temporary Redirect.
    • 308: Permanent Redirect.
  • use_custom_host: Managing the Host header:

    • true: Using the Host header from the primary origin. For example, if the example.com origin returns a redirect to ya.ru, the request will be sent with Host: example.com.
    • false: Using the Host header from the redirect domain. For example, if the example.com origin returns a redirect to ya.ru, the request will be sent with Host: ya.ru.

ExampleExample

In this example, we will create a CDN resource for an online store that uses multiple domains. The primary origin, shop.example.com, can redirect requests to cdn-content.example.net to optimize delivery of static files. Here, we are allowed to follow redirects for codes 301 and 302 while preserving the original Host header to correctly process the requests.

  1. Get an IAM token for API authentication and write it into a variable:

    export IAM_TOKEN=`yc iam create-token`
    
  2. Create a CDN resource that allows to follow request redirects:

    cURL
    gRPCurl
    curl \
      --request POST \
      --header "Authorization: Bearer $IAM_TOKEN" \
      --header "Content-Type: application/json" \
      --url 'https://cdn.api.cloud.yandex.net/cdn/v1/resources' \
      --data '{
        "folderId": "b12m81qm6abc********",
        "cname": "cdn-shop.example.com",
        "origin": {
          "originSourceParams": {
            "source": "shop.example.com",
            "meta": {
              "common": { "name": "shop.example.com" }
            }
          }
        },
        "originProtocol": "HTTPS",
        "options": {
          "followRedirects": {
            "enabled": true,
            "codes": ["301", "302"],
            "useCustomHost": true
          }
        }
      }'
    

    Result:

    {
    "done": true,
    "metadata": {
      "@type": "type.googleapis.com/yandex.cloud.cdn.v1.CreateResourceMetadata",
      "resourceId": "bc8rt2ynimae********"
    },
    "response": {
      ...
      "followRedirects": {
        "enabled": true,
        "codes": [
        "301",
        "302"
        ],
        "useCustomHost": true
      }
      },
      ...
    "id": "bc82j4x6n6pb********",
    "description": "Create resource",
    "createdAt": "2026-02-03T09:27:51.714683Z",
    "createdBy": "aje9k8luj4qf********",
    "modifiedAt": "2026-02-03T09:27:51.714683Z"
    }
    
    grpcurl \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "folder_id": "b12m81qm6abc********",
            "cname": "cdn-shop.example.com",
            "origin": {
              "origin_source_params": {
                "source": "shop.example.com",
                "meta": {
                  "common": { "name": "shop.example.com" }
                }
              }
            },
            "origin_protocol": "HTTPS",
            "options": {
              "follow_redirects": {
                "enabled": true,
                "codes": ["301", "302"],
                "use_custom_host": true
              }
            }
          }' \
      cdn.api.cloud.yandex.net:443 \
      yandex.cloud.cdn.v1.ResourceService/Create
    

    Result:

    {
      "id": "bc87tcdmptuy********",
      "description": "Create resource",
      "createdAt": "2026-02-03T09:09:04.967980Z",
      "createdBy": "aje8m8lur3qf********",
      "modifiedAt": "2026-02-03T09:09:04.967980Z",
      "done": true,
      "metadata": {"@type":"type.googleapis.com/yandex.cloud.cdn.v1.CreateResourceMetadata","resourceId":"bc8rskqqnd23********"},
      "response": {"@type":"type.googleapis.com/yandex.cloud.cdn.v1.Resource","active":true,"cname":"altaraskin.online","createdAt":"2026-02-03T09:09:04.808428Z","folderId":"b1g652qoimb4********","id":"bc8rskqqnd23********","options":{ ... "followRedirects":{"enabled":true,"codes":["301","302"],"useCustomHost":true}}, ... }
    }
    
  3. Enable origin shielding:

    Management console
    gRPCurl
    1. In the management console, select the folder where your resource is located.
    2. Navigate to Cloud CDN.
    3. Click the resource name.
    4. Navigate to the Origin shielding tab.
    5. In the top-right corner, enable the origin shielding option.
    6. In the Shielding settings window, select the required location in the Location field.
    7. Click Activate.

    Once enabled, the shielding status will change from Not activated to Active.

    grpcurl \
      -import-path ~/cloudapi/ \
      -import-path ~/cloudapi/third_party/googleapis/ \
      -proto ~/cloudapi/yandex/cloud/cdn/v1/shielding_service.proto \
      -rpc-header "Authorization: Bearer $IAM_TOKEN" \
      -d '{
            "resource_id": "bc8rskqqnd23********",
            "location_id": "1"
          }' \
      cdn.api.cloud.yandex.net:443 \
      yandex.cloud.cdn.v1.ShieldingService/Activate
    

    Result:

    {
      "id": "bc8yiwltf3hg********",
      "description": "Activate Origin Shielding",
      "createdAt": "2026-02-03T09:13:43.226165Z",
      "createdBy": "aje9k8luj4qf********",
      "modifiedAt": "2026-02-03T09:13:43.226165Z",
      "done": true,
      "metadata": {"@type":"type.googleapis.com/yandex.cloud.cdn.v1.ActivateShieldingMetadata","resourceId":"bc8rskqqnd23********"},
      "response": {"@type":"type.googleapis.com/yandex.cloud.cdn.v1.ShieldingDetails","city":"Moscow","country":"Russia","dataCenter":"msk","locationId":"1"}
    }
    

Was the article helpful?

Previous
Setting up a request redirect
Next
Setting up hiding of origin headers
© 2026 Direct Cursus Technology L.L.C.