Global Action

For different applications, some actions are often the same, such as setting the proxy header.

By putting these actions in the Global Action, you can just direct reference them in an application if you need to.

Any modifications that may happen can be made once and for all in the Global Action, without the trouble of modifying them one application after another, making the logic more concise and clear.

Below is an introduction to how to add a global action and reference it in the application.

First, click Global Config:

Then, click on Global Custom Action on the left-side navigation bar to enter the Global Action page.

This page lists global actions that already exist. Click the Add User-defined Action button to create one.

Similar to the Page Rules of application, this page contains Enable Conditions and Action, but it also has the unique action name field.

Below is a simple example.

The Page Rules drop-down list contains a variety of actions, and one of them is “Proxy Action”. Select Set Proxy Header from this category:

Set proxy header involves the name and value of the proxy header. The latter is set by manually inputting the character string or selecting from built-in variables.

Selecting from built-in variables is a more common method. Here is an example.

Set the name of the proxy header at x-real-ip, and its value is the IP address of the client-side.

Click the Create button on the bottom right-hand corner, and a global action is set successfully.

Now, let’s see how to use the global custom action we just created in an application.

First, come to the Page Rules page of the application.

Click the New Rule button first.

Then, click the Add a new action button.

Among the actions in the Page Rules drop-down list is Global Custom Action.

Select the custom action added in the previous step: set-proxy-header-of-real-ip.

Click the Create button on the bottom right-hand corner to reference a global action in the application. All settings are done.