Edge Route Traffic Policy Module
Replace HTTPS Edge Route Traffic Policy Module
Request
PUT /edges/https/{edge_id}/routes/{id}/traffic_policy
Example Request
curl \
-X PUT \
-H "Authorization: Bearer {API_KEY}" \
-H "Content-Type: application/json" \
-H "Ngrok-Version: 2" \
-d '{"enabled":true,"value":"{\n\t\"on_http_request\":[\n\t\t{\n\t\t\t\"name\":\"Rewrite /products API Calls\",\n\t\t\t\"expressions\":[\"req.url.path == '/products'\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\": \"url-rewrite\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"from\": \"/products/?([.*]+)?\",\n\t\t\t\t\t\t\"to\": \"/products.php?query=$1\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block POST Requests With Large Content Length From Specific Countries\",\n\t\t\t\"expressions\":[\n\t\t\t\t\"req.method == 'POST' && req.content_length > 10000\",\n\t\t\t\t\"conn.geo.country_code in ['BR', 'CN', 'CU', 'IR', 'NG', 'RO', 'RU', 'SD', 'SY', 'UA']\"\n\t\t\t],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"custom-response\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":401,\n\t\t\t\t\t\t\"headers\":{\n\t\t\t\t\t\t\t\"content-type\":\"text/plain\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"content\":\"access denied\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block AI Crawler Bots\",\n\t\t\t\"expressions\":[\"'ChatGPT' in req.headers['user-agent'] || 'GPTBot' in req.headers['user-agent']\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"deny\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":400\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t],\n\t\"on_http_response\":[\n\t\t{\n\t\t\t\"name\":\"Brotli Compress Responses\",\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"compress-response\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"algorithms\":[\"br\"]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}"}' \
https://api.ngrok.com/edges/https/edghts_2na2LH4q1ecRxyKOIunSLp6p6ly/routes/edghtsrt_2na2LKqlw9s5QJvTydy2K5dtZ5g/traffic_policy
Parameters
Name | Type | Description |
---|---|---|
enabled | boolean | true if the module will be applied to traffic, false to disable. default true if unspecified |
value | string | the traffic policy that should be applied to the traffic on your endpoint. |
Response
Returns a 200 response on success
Example Response
{
"enabled": true,
"value": "{\n\t\"on_http_request\":[\n\t\t{\n\t\t\t\"name\":\"Rewrite /products API Calls\",\n\t\t\t\"expressions\":[\"req.url.path == '/products'\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\": \"url-rewrite\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"from\": \"/products/?([.*]+)?\",\n\t\t\t\t\t\t\"to\": \"/products.php?query=$1\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block POST Requests With Large Content Length From Specific Countries\",\n\t\t\t\"expressions\":[\n\t\t\t\t\"req.method == 'POST' && req.content_length > 10000\",\n\t\t\t\t\"conn.geo.country_code in ['BR', 'CN', 'CU', 'IR', 'NG', 'RO', 'RU', 'SD', 'SY', 'UA']\"\n\t\t\t],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"custom-response\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":401,\n\t\t\t\t\t\t\"headers\":{\n\t\t\t\t\t\t\t\"content-type\":\"text/plain\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"content\":\"access denied\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block AI Crawler Bots\",\n\t\t\t\"expressions\":[\"'ChatGPT' in req.headers['user-agent'] || 'GPTBot' in req.headers['user-agent']\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"deny\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":400\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t],\n\t\"on_http_response\":[\n\t\t{\n\t\t\t\"name\":\"Brotli Compress Responses\",\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"compress-response\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"algorithms\":[\"br\"]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}"
}
Fields
Name | Type | Description |
---|---|---|
enabled | boolean | true if the module will be applied to traffic, false to disable. default true if unspecified |
value | string | the traffic policy that should be applied to the traffic on your endpoint. |
Get HTTPS Edge Route Traffic Policy Module
Request
GET /edges/https/{edge_id}/routes/{id}/traffic_policy
Example Request
curl \
-X GET \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/edges/https/edghts_2na2LH4q1ecRxyKOIunSLp6p6ly/routes/edghtsrt_2na2LKqlw9s5QJvTydy2K5dtZ5g/traffic_policy
Response
Returns a 200 response on success
Example Response
{
"enabled": true,
"value": "{\n\t\"on_http_request\":[\n\t\t{\n\t\t\t\"name\":\"Rewrite /products API Calls\",\n\t\t\t\"expressions\":[\"req.url.path == '/products'\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\": \"url-rewrite\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"from\": \"/products/?([.*]+)?\",\n\t\t\t\t\t\t\"to\": \"/products.php?query=$1\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block POST Requests With Large Content Length From Specific Countries\",\n\t\t\t\"expressions\":[\n\t\t\t\t\"req.method == 'POST' && req.content_length > 10000\",\n\t\t\t\t\"conn.geo.country_code in ['BR', 'CN', 'CU', 'IR', 'NG', 'RO', 'RU', 'SD', 'SY', 'UA']\"\n\t\t\t],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"custom-response\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":401,\n\t\t\t\t\t\t\"headers\":{\n\t\t\t\t\t\t\t\"content-type\":\"text/plain\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\t\"content\":\"access denied\"\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\t{\n\t\t\t\"name\":\"Block AI Crawler Bots\",\n\t\t\t\"expressions\":[\"'ChatGPT' in req.headers['user-agent'] || 'GPTBot' in req.headers['user-agent']\"],\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"deny\",\n\t\t\t\t\t\"config\":{\n\t\t\t\t\t\t\"status_code\":400\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t],\n\t\"on_http_response\":[\n\t\t{\n\t\t\t\"name\":\"Brotli Compress Responses\",\n\t\t\t\"actions\":[\n\t\t\t\t{\n\t\t\t\t\t\"type\":\"compress-response\",\n\t\t\t\t\t\"config\": {\n\t\t\t\t\t\t\"algorithms\":[\"br\"]\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t}\n\t]\n}"
}
Fields
Name | Type | Description |
---|---|---|
enabled | boolean | true if the module will be applied to traffic, false to disable. default true if unspecified |
value | string | the traffic policy that should be applied to the traffic on your endpoint. |
Delete HTTPS Edge Route Traffic Policy Module
Request
DELETE /edges/https/{edge_id}/routes/{id}/traffic_policy
Example Request
curl \
-X DELETE \
-H "Authorization: Bearer {API_KEY}" \
-H "Ngrok-Version: 2" \
https://api.ngrok.com/edges/https/edghts_2na2LH4q1ecRxyKOIunSLp6p6ly/routes/edghtsrt_2na2LKqlw9s5QJvTydy2K5dtZ5g/traffic_policy
Response
Returns a 204 response with no body on success