> ## Documentation Index
> Fetch the complete documentation index at: https://gcore-doc-1256a.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Extend CDN functionality with FastEdge

Integrate your CDN resource with FastEdge if you need to **introduce additional functionality** to Gcore CDN and customize its behavior for various use cases.

Such a setup allows you to extend the CDN beyond standard features and implement advanced logic for:

* Authentication checks. Deploy FastEdge apps based on the JWT authentication template or develop a custom authentication functionality.
* Custom headers modification. Adjust header information on requests for personalized and more secure content delivery.
* Custom access rules. Use advanced geo-blocking and time-based blocking to control user access to your content and mitigate potential threats.

## How it works

Unlike traditional HTTP applications, a CDN application in FastEdge must be developed according to the [Proxy-Wasm (WebAssembly for Proxies)](https://github.com/proxy-wasm/spec) specification. This ensures compatibility and standardization across different CDN environments.

The application is called at the early stage of CDN processing, allowing for immediate intervention and customization. We're actively working on new interception points across the CDN workflow to cover many use cases.

The FastEdge application can be invoked at the following stages of the CDN processing workflow:

* **On request headers:** when we receive an HTTP request from a client.
* **On request body:** when we receive an HTTP request body from a client.
* **On response headers:** before we start sending HTTP response headers to a client.
* **On response:** before?we start sending an HTTP response to a client.

<Info>You can only configure **one application per stage**.</Info>

## Set up FastEdge integration with the CDN

To get started, you need a CDN resource configured for your origin. If you don't have Gcore CDN set up, follow the instructions in this guide: [Create a CDN resource](/cdn/getting-started/create-a-cdn-resource/overview).

### Step 1. Create a FastEdge application

You can deploy an application from a predefined template or from a custom Wasm file. If you choose the latter option, ensure your Wasm binary file complies with the [WebAssembly standard for proxies](https://github.com/proxy-wasm/spec).

<Tabs>
  <Tab title="Deploy from the template">
    Currently, you can use a predefined template to enable authentication in your application. The template is configured to verify the JSON Web Token (JWT) in the request header.

    To deploy an application from the template:

    1. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**.
    2. Open the **CDN Applications** page and click **Create new application**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png" alt="Create FastEdge application button" />
    </Frame>

    3. In the **Create from a template** section, choose **Validate JWT in Authorization header**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/validate-jwt.png" alt="Create from a template section with jwt validation template" />
    </Frame>

    4. Enter a name for your application and, optionally, update its description.
    5. Add required environment variables, such as a token signing key that will be used for authentication checks.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-from-template-setup.png" alt="JWT template configuration menu" />
    </Frame>

    6. Click **Save and deploy**.

    Your application has been successfully deployed and can now be accessed through the CDN.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-created.png" alt="A page with app deployment confirmation" />
    </Frame>

    If you need to adjust the configuration, click **Actions** > **Edit application**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app-from-template.png" alt="A page with app deployment confirmation" />
    </Frame>
  </Tab>

  <Tab title="Deploy a custom CDN application">
    If you want to deploy a FastEdge application from your own binary, check the examples of custom implementation in our repository: [FastEdge application examples](https://github.com/G-Core/FastEdge-examples).

    To deploy a FastEdge application from your own binary:

    1\. In the [Gcore Customer Portal](https://portal.gcore.com/accounts/reports/dashboard), navigate to **FastEdge**.
    2\. Open the **CDN Applications** page and click **Create new application**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-page-create-app.png" alt="Create FastEdge application button" />
    </Frame>

    3\. Click **Upload binary**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-apps-upload-binary.png" alt="Create custom application section" />
    </Frame>

    4\. Choose your custom binary file.

    <Frame>
      <img src="https://mintcdn.com/gcore-doc-1256a/8L3rBxTmAbw-k--g/images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png?fit=max&auto=format&n=8L3rBxTmAbw-k--g&q=85&s=00c866c6e41ff2a9e59194fe7c7ee857" alt="Add raw binary dialog" width="481" height="324" data-path="images/docs/fastedge/getting-started/create-fastedge-apps/upload-binary-dialog.png" />
    </Frame>

    5. Enter a name for your application and, optionally, add a description.
    6. Add required environment variables that will be used for authentication checks. Enter the data as key-value pairs.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-app-setup.png" alt="Custom app configuration menu" />
    </Frame>

    <Info>
      **Info**

      If you're adding sensitive information or want to ensure that any data in the app's configuration remains secure, click **+ Add Secret** and use the [Secrets Manager](/fastedge/secrets-manager/manage-secrets).
    </Info>

    7. Click **Save and deploy**.

    Your application has been successfully deployed and can now be referenced from CDN resource settings. To adjust the configuration, click **Actions** > **Edit application**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/actions-edit-app.png" alt="A page with app deployment confirmation" />
    </Frame>
  </Tab>
</Tabs>

### Step 2. Enable FastEdge functions for your CDN resource

You can enable the configured Wasm functionality for the whole CDN resource or just some URLs.

<Tabs>
  <Tab title="For a whole CDN resource">
    1. In the Gcore Customer Portal, navigate to **CDN**.
    2. Find the resource you want to integrate with FastEdge and open the **resource settings**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png" alt="CDN resources page with resource settings context menu" />
    </Frame>

    3. Scroll the page down to the **FastEdge apps** section and enable the toggle for the event you need.

       Currently, we support four events: **On request headers**, **on request body**, **on response headers**, and **on response body**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/cdn-fast-edge-1.png" alt="Cdn Fast Edge 1 Pn" style={{ width:"78%" }} />
    </Frame>

    4. Choose your application from the dropdown.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/cdn-fast-edge-2.png" alt="Cdn Fast Edge 2 Pn" style={{ width:"78%" }} />
    </Frame>

    5. (Optional) **Select the Interrupt request processing in case of error** checkbox.

    <Info>
      **Info**

      The **Interrupt request processing in case of error** checkbox is enabled by default. This ensures that any errors on the FastEdge side will be returned to the browser with the relevant response code. If you disable the checkbox, CDN will ignore the error and pass requests directly to the origin. For security considerations, we recommend keeping this checkbox active.
    </Info>

    6. Click **Save**.
  </Tab>

  <Tab title="For specific URL paths">
    You can set up a function within your uploaded FastEdge application to manage incoming request headers only for specific URLs. For example, protect some parts of your content with a JWT token, and keep the other URLs unaffected.

    To enable the function for specific URLs:

    1. In the Gcore Customer Portal, navigate to **CDN**.
    2. Find the resource you want to integrate with FastEdge and open the resource settings.
    3. Click **Rules** > **Create rule**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-settings-rules-section.png" alt="CDN resource settings with open Rules tab" />
    </Frame>

    4. Click **Create blank rule**.
    5. Give your rule a name.
    6. In the **Match criteria** section, specify the content affected by the function configured in your FastEdge application.
    7. In the **Options** section, click **Add option**.
    8. Scroll the page down to the **FastEdge apps** section and enable the toggle for the event you need.

       Currently, we support four events: **On request headers**, **on request body**, **on response headers**, and **on response body**.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/cdn-fast-edge-1.png" alt="Cdn Fast Edge 1 Pn" style={{ width:"75%" }} />
    </Frame>

    9. Choose your application from the dropdown.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/cdn-fast-edge-2.png" alt="Cdn Fast Edge 2 Pn" style={{ width:"76%" }} />
    </Frame>

    10. (Optional) **Select the Interrupt request processing in case of error** checkbox.

    <Frame>
      <img src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/rule-options-fastedge-app-enable.png" alt="Enable FastEdge apps section in rule options dialog" />
    </Frame>

    <Info>
      **Info**

      The **Interrupt request processing in case of error** checkbox is enabled by default. This ensures that any errors on the FastEdge side will be returned to the browser with the relevant response code.

      If you disable the checkbox, CDN will ignore the error and pass requests directly to the origin. For security considerations, we recommend keeping this checkbox active.
    </Info>

    12. Click **Create rule**.
  </Tab>
</Tabs>

## Disconnect FastEdge from CDN

If you no longer need to use the functionality configured in your FastEdge application, you can disable the FastEdge functions for your CDN resource.

The steps will slightly differ depending on whether you remove FastEdge from **the whole CDN resource or just specific URLs**.

1. In the Gcore Customer Portal, navigate to **CDN**.
2. Find the resource integrated with FastEdge and open the **resource settings**.

<Frame>
  <img
    src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/cdn-resource-settings-button.png"
    alt="CDN resources page with resource settings context
menu"
  />
</Frame>

3. If you enabled FastEdge for a **whole CDN resource**, disable the toggles you no longer need.
4. If you enabled FastEdge just for **particular paths**, open the **Rules** page and disable the toggle for the required rule.
5. Click **Save changes**.

You've successfully disconnected your CDN resource from FastEdge.

## Delete CDN application in FastEdge

<Info>
  **Info**

  **You can't delete an enabled FastEdge application connected to a CDN resource**. To remove the application, disconnect it from the CDN resource first.
</Info>

To delete an application:

1. In the Gcore Customer Portal, navigate to **FastEdge**.
2. Open the **CDN Applications** page and click the three-dot icon next to the application that you want to remove.

<Frame>
  <img
    src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/remove-app-fstedge.png"
    alt="FastEdge app settings with delete
button"
  />
</Frame>

3. Click **Delete**.
4. Confirm your action by clicking **Yes, delete**.

<Frame>
  <img
    src="https://mintlify.s3.us-west-1.amazonaws.com/gcore-doc-1256a/images/docs/cdn/getting-started/integrate-cdn-with-fastedge/confirm-deletion.png"
    alt="Confirm app deletion
dialog"
  />
</Frame>

You've successfully removed your CDN application from Gcore FastEdge.
