All Products
Search
Document Center

Edge Security Acceleration:Gzip compression failure for or DCDN back-to-origin requests

Last Updated:Jun 17, 2026

Problem description

The origin server for DCDN is an Nginx server with Gzip compression enabled. Gzip compression works as expected when a client directly requests the origin server, but fails for back-to-origin requests.

When gzip compression is enabled, Nginx returns compressed content to reduce traffic overhead and accelerate response speed. However, after you enable DCDN, requests are forwarded through DCDN, but the client ultimately receives uncompressed content. When DCDN sends a back-to-origin request, the gzip feature on the origin server does not take effect.

  • Without or DCDN A request header with Accept-Encoding: gzip, deflate results in a response header with Content-Encoding: gzip, which indicates that the content is compressed.

  • With or DCDN A request header with Accept-Encoding: gzip, deflate results in a response header that includes Content-Length but not Content-Encoding: gzip.

Cause

The Gzip configuration on the origin Nginx server is incorrect, and Gzip compression is not enabled for back-to-origin requests from or DCDN.

When a client request is forwarded to the origin server through DCDN, the Via field is added to the back-to-origin request header to indicate that the request comes from a proxy server (in this case, DCDN). The ngx_http_gzip_module module in Nginx provides a gzip_proxied directive that controls Gzip compression for proxied requests. One prerequisite for this directive is that the request header contains the Via field. Therefore, the gzip_proxied directive determines whether Gzip compression is enabled for back-to-origin requests.

Solution

If your problem matches the one described in Problem description, follow these steps to update the Nginx configuration. If you are unsure about the symptoms, see More information to verify first.

  1. Locate the gzip configuration block in Nginx. These directives can be placed in the http, server, or location blocks, so the relevant configuration file may vary. In this topic's example, the gzip configuration is in the http block of the nginx.conf file.

  2. In your gzip configuration, check for the gzip_proxied directive. Modify it to match the following configuration, or add the directive if it does not exist. For more information about the gzip_proxied directive, see the official Nginx documentation.

    Note

    If the gzip_proxied directive is not specified, it defaults to off.

    gzip_proxied  any
    Note

    The any parameter enables compression for all requests from a proxy server.

  3. After saving the configuration, run the following commands to check and reload the Nginx configuration.

    nginx -t
    nginx -s reload
  4. With or DCDN enabled, send a client request that is forwarded to the Nginx . Confirm that the response header now contains Content-Encoding: gzip, indicating the content is compressed.

More information

To confirm that your issue matches the one described in the Problem description section, run the following test:

  1. Use any client that supports the curl command.

  2. Run the following curl command to directly access the origin server. Include the Accept-Encoding: gzip, deflate header in the request.

    curl -voa 'http://[$Domain]/[$Resource]' -x [$Original_Server_IP]:80 -H 'Accept-Encoding: gzip, deflate'
    Note
    • [$Domain]: Your domain name.

    • [$Resource]: The request URL for a resource on a website, such as an image or an API interface.

    • [$Original_Server_IP]: The public IP address of the origin Nginx server.

    The response is similar to the following. Verify that the response header contains Content-Encoding: gzip.

  3. Refer to the following command, which adds a Via field to the command from Step 2 to simulate a request from a proxy server.

    curl -voa 'http://[$Domain]/[$Resource]' -x [$Original_Server_IP]:80 -H 'Accept-Encoding: gzip, deflate' -H 'Via:xxx'
    Note

    You can use any value for the Via header, since it does not affect the test result. This example uses some-proxy.

    The response is similar to the following. Verify that the response header contains Content-Length and does not contain Content-Encoding: gzip.