List of rule and action type that can be set for Actions
In the KurocoEdge rule addition screen, you can set actions for requests and responses, which are referred to as operations. You can set rules and processes for actions and configure how they behave when accessed.
Here, we will explain the rules and processes that can be set for each action for both requests and responses.
Action creation screen
On the rule list page, you can create a new rule by clicking [Add].
Set each action on the request and response tabs.
Rule structure explanation
Each rule may define any number of actions for either Request or Response. The actions are processed in order of priority from highest to lowest.
Each action has the following configuration options :
Name | Explanation |
---|---|
Directive Flag | Optional configuration that affects general behavior of the current action |
Condition/Variable | The conditions that all need to be verified in order for the action settings to be processed. Most conditions also allow to capture data and store it as variables for further use |
Settings | The list of settings to apply to the given request/response. They are appplied in order (highest first) |
Request and Response tabs have each access to their own set of meaningful conditions & settings for their context.
Capturing named variables in regex is done like this :(?P<my_variable>.*)
And using them is done like this :{$my_variable}
Request
On Request tab, the rules apply to the requests issued by the browser before they reach the origin backend.
Conditions that can be set for requests
Field | Settings | Description |
---|---|---|
Method | Request Method | OK if the request's method matches the specified one :
|
IP Address | IP address pattern | Apply a (possibly capturing) regex to the IP address of the user |
Geolocation | Type, Value pattern | Select the type of position information from the following and set conditions with regular expressions:
|
Path | Path pattern | Apply a (possibly capturing) regex to the request path |
Query String | Name, Value pattern | Apply a (possibly capturing) regex to the value of the given query parameter by name |
Header | Header field, Value pattern | Apply a (possibly capturing) regex to the value of the given header by name |
Cookie | Key, Value pattern | Apply a (possibly capturing) regex to the value of the given cookie by name. Cookies are parsed from the cookie header before any rule applies (including those potentially changing Cookie header) |
Body | Body pattern | Buffer the entire request body in the memory and apply a (possibly capturing) regex to it. Beware of capturing large request bodies. When buffering bodies, memory consumption for each request is increased. And Edge services is pay per use, so using more memory costs more money to the client. There is also a risk to go beyond the allowed limit and have request failure, in addition to the cost |
Body prefix | ByteSize, Body pattern | Buffer a given amount of first bytes of the request body in memory, and apply a (possibly capturing) regex to these only. It is a more performant option than Body in case of large bodies, when the required data is located early |
Static Variables | Variable name, Value | Define a string variable directly within the rule. The value may use other previously captured variables |
API Variables | API endpoint, Cache, First byte timeout, Method, Headers, Expected variable(s), Request cookies to be forwarded to the API | Execute an external API request, and build variables from the response. JSON object response body is expected. All API requests defined within the same rule |
Match Value | Expression, Value pattern | Matches left side expression with the right one. Captured variables may be used on either side |
Processes that can be set for requests
Field | Settings | Description |
---|---|---|
Header | Operation, header field, Value, URL encode | "Add or Replace" inserts new header or overwrites if one already exists, where "Match & Replace" allows to match & replace only the captured parts of the value using a regex |
Cookie | Operation, Name, Value | "Add or Replace" inserts new cookie or overwrites if one already exists, where "Match & Replace" allows to match & replace only the captured parts of the value using a regex |
FilePath(in Filemanager) | File manager | Maps this request to return whatever is at the given path in the Filemanager of the connected Kuroco admin panel. In set, this request will not be forwarded to the default origin backend |
Backend URL | Domain, Path | Specify a destination where this request will be forwarded. This allows to route requests from the same frontend to multiple backends at once |
Synthetic Response | HTTP Status, Content Type, Body HTML, Headers | Respond with a handcrafted synthetic response. Optionnally additional response headers may be specified. Captured variables may be used in the body or header values |
Redirect URL | HTTP Status, URL | Select the redirect method and enter the URL of the redirect destination. The following redirect methods are available:
|
Response
On Response tab, the rules apply to the response issued by the origin server before it is sent back to the user
Conditions that can be set for response
Field | Settings | Description |
---|---|---|
HTTP status | HTTP response status code pattern | Apply a (possibly capturing) regex to the HTTP status code (200, 404, etc) |
Header | Name, Value pattern | Apply a (possibly capturing) regex to the value of the given header by name |
Cookie | Operation, Name, Value | "Add or Replace" inserts new cookie or overwrites if one already exists, where "Match & Replace" allows to match & replace only the captured parts of the value using a regex |
BodyPrefix | Bytesize, Body pattern | Buffer a given amount of first bytes of the response body in memory, and apply a (possibly capturing) regex to these only. It is a more performant option than Body in case of large bodies, when the required data is located early |
Static Variables | Name, Value | Define a string variable directly within the rule. The value may use other previously captured variables |
API Variables | URL | Execute an external API request, and build variables from the response. JSON object response body is expected. All API requests defined within the same rule. Use Preload option to dispatch the request early to execute it in parallel with the origin request if the origin response data is not needed for this API call |
Match valiable value | Value, Match | Matches left side expression with the right one. Captured variables may be used on either side |
Processes that can be set for response
Field | Settings | Description |
---|---|---|
HTTP status | HTTP response status code pattern | Set the HTTP status code (such as 200, 404, etc.). |
Header | Operation, Name, Value | "Add or Replace" inserts new header or overwrites if one already exists, where "Match & Replace" allows to match & replace only the captured parts of the value using a regex |
Cookie | Operation, Name, Value | "Add or Replace" inserts new cookie or overwrites if one already exists, where "Match & Replace" allows to match & replace only the captured parts of the value using a regex |
Browser Cache | TTL (max-age) | Set the number of seconds for this request be cached for in the browser |
Edge Cache | TTL (max-age) | Set the number of seconds for this request be cached for on the Edge |
HTML Crawl | CSS Selector, JSON Path, JSON Value list | Use this feature to capture parts of of the HTML body. The captured data can be used in a ShadowApi formatter to be injected either at the end of the body in a script tag as a JS variable, or the whole response can be changed to output the captured JSON variables only (instead of HTML) |
Text Replace | from, to | Replace the text in the response with the specified text before and after replacement. |
HTML Editor | Click "Edit" and open the setting modal | Refer to the HTML Edit section for detailed instructions. |
Synthetic Response | HTTP Status, Content Type, Body HTML, Headers | Respond with a handcrafted synthetic response. Optionnally additional response headers may be specified. Captured variables may be used in the body or header values |
Redirect URL | HTTP Status, URL | Select the redirect method and enter the URL of the redirect destination. The following redirect methods are available:
|
HTML Editor
In HTML editor, you can make modifications to the HTML that KurocoEdge retrieves from the backend host before responding to the browser.
Field | Description |
---|---|
General | Specify the range of HTML to be edited using CSS selectors. Optionally, selecting "Hide" will set display: none; for the specified range. Optionally, selecting "Delete" will remove the specified range. |
Tag Attributes | You can add, remove, or replace tags for the elements specified by CSS selectors. |
Tag Content | Add text to the elements specified by CSS selectors. If there are child elements, the specified text will be added to each element. |
HTML Injection | Insert additional HTML into the elements specified by CSS selectors. Choose the position to insert the HTML from the following options:
|
Support
If you have any other questions, please contact us or check out Our Discord Community.