Using EdgeOne Pages as a Reverse Proxy: A Comprehensive Guide

Ethan MercerEthan Mercer
5 min read
Spt 5, 2025

proxy.jpg

One of EdgeOne Pages advanced features is the ability to act as a reverse proxy, allowing you to forward client requests to your backend servers securely and efficiently. This article will guide you through the process of configuring EdgeOne Pages as a reverse proxy using the edgeone.json configuration file.

How to Use EdgeOne Pages Rewrites for Reverse Proxy

EdgeOne Pages provides the “edgeone.json” configuration file to customize project build and deployment behaviors (such as build commands) and manage routing strategies (including redirects, rewrites, and HTTP response headers).

Rewrites allow you to transparently route user requests to different URLs without changing the visible URL in the browser. With rewrites, you can modify the URL path, query parameters, and request headers before the request reaches your backend server.

Basic Rewrite Example

This example rewrites all requests starting with /assets/ to the /assets-new/ directory, while preserving the original path portion of the request.

{
  "rewrites": [
    {
      "source": "/assets/*",
      "destination": "/assets-new/:splat",
    }
  ]
}

Refined Rewrite for Specific File Types

We can further refine rewriting rules, specifically targeting image files in PNG format. The following example will ensure that all requests ending with .png are rewritten to a new path, while preserving the filename.

{
  "rewrites": [
    {
      "source": "/assets/(.*).png",
      "destination": "/assets-new/$1.png",
    }
  ]
}

Notes and Limitations

MatterRestrictions
Maximum number of rules30
Maximum length for src and dest500 characters
Applicable scopeThese rewrite rules are only effective for static resource access.
SPA LimitationRewrites do not support frontend route rewriting for SPA.
Path requirementThe src path must start with /.

For more proxy settings about EdgeOne, you can check EdgeOne's usage documentation.

SPA Application Rewriting Suggestions

If you need to implement URL rewriting in SPA, the following solutions are recommended:

  • Use the routing system built into the framework for path redirection
  • Define rewriting rules in the routing configuration

Conclusion

EdgeOne Pages makes it simple to set up a reverse proxy for your applications. By configuring the "edgeone.json" file, you can securely and efficiently route traffic to your backend services, leveraging the power of Tencent EdgeOne’s global infrastructure.