ACLs
An ACL matches on properties of a request — host, path, headers — and decides which backend serves it. One is created with every Virtual Service to link its frontend to its backend.
ACLs
curl
curl -X GET "https://appliance.example.com/api/v1/haproxy/acls" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls';
$headers = [
'Authorization: Bearer ' . $token,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
response = requests.get("https://appliance.example.com/api/v1/haproxy/acls", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL retrieved successfully",
"data": [
{
"id": "5cf-7c9-e9d-908",
"name": "Block admin from outside the office",
"enabled": true,
"conditionSet": {
"operator": "or",
"terms": [
{
"operator": "and",
"conditionGroups": [
{
"operator": "or",
"negate": false,
"conditions": [
{
"conditionType": "pathBeg",
"condition": "eq",
"conditionValues": [
"/admin"
]
}
]
},
{
"operator": "or",
"negate": true,
"conditions": [
{
"conditionType": "srcBlk",
"condition": "eq",
"conditionValues": [
"10.0.0.0/8"
]
}
]
}
]
}
]
},
"redirectType": "deny",
"redirectCode": 403
}
]
}
curl
curl -X POST "https://appliance.example.com/api/v1/haproxy/acls" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"enabled": "true",
"rawEnabled": "false",
"rawBlock": "<rawBlock>",
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}'
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls';
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$payload = [
'name' => '<name>',
'enabled' => 'true',
'rawEnabled' => 'false',
'rawBlock' => '<rawBlock>',
'conditionSet' => [],
'conditionType' => '<conditionType>',
'conditionParam' => '<conditionParam>',
'conditionValues' => [
'<conditionValues>',
],
'condition' => '<condition>',
'redirectType' => 'none',
'redirectLocation' => '<redirectLocation>',
'redirectParam' => '<redirectParam>',
'redirectMatch' => '<redirectMatch>',
'captureLength' => 0,
'redirectCode' => 0,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
payload = {
"name": "<name>",
"enabled": "true",
"rawEnabled": "false",
"rawBlock": "<rawBlock>",
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}
response = requests.post("https://appliance.example.com/api/v1/haproxy/acls", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "<name>",
"enabled": "true",
"rawEnabled": "false",
"rawBlock": "<rawBlock>",
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}),
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL added successfully",
"data": {
"id": "5ce-68c-589-22d"
}
}
List the Layer 7 ACLs with pending changes
curl
curl -X GET "https://appliance.example.com/api/v1/haproxy/acls/hanging" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls/hanging';
$headers = [
'Authorization: Bearer ' . $token,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
response = requests.get("https://appliance.example.com/api/v1/haproxy/acls/hanging", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls/hanging', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL retrieved successfully",
"data": [
{
"id": "5cf-7c9-e9d-908",
"name": "Block admin from outside the office",
"enabled": true,
"conditionSet": {
"operator": "or",
"terms": [
{
"operator": "and",
"conditionGroups": [
{
"operator": "or",
"negate": false,
"conditions": [
{
"conditionType": "pathBeg",
"condition": "eq",
"conditionValues": [
"/admin"
]
}
]
},
{
"operator": "or",
"negate": true,
"conditions": [
{
"conditionType": "srcBlk",
"condition": "eq",
"conditionValues": [
"10.0.0.0/8"
]
}
]
}
]
}
]
},
"redirectType": "deny",
"redirectCode": 403
}
]
}
Generate a raw ACL block
curl
curl -X POST "https://appliance.example.com/api/v1/haproxy/acls/raw-block" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "<redirectType>",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0,
"name": "<name>",
"enabled": true,
"rawEnabled": true,
"rawBlock": "<rawBlock>"
}'
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls/raw-block';
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$payload = [
'conditionSet' => [],
'conditionType' => '<conditionType>',
'conditionParam' => '<conditionParam>',
'conditionValues' => [
'<conditionValues>',
],
'condition' => '<condition>',
'redirectType' => '<redirectType>',
'redirectLocation' => '<redirectLocation>',
'redirectParam' => '<redirectParam>',
'redirectMatch' => '<redirectMatch>',
'captureLength' => 0,
'redirectCode' => 0,
'name' => '<name>',
'enabled' => true,
'rawEnabled' => true,
'rawBlock' => '<rawBlock>',
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
payload = {
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "<redirectType>",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0,
"name": "<name>",
"enabled": true,
"rawEnabled": true,
"rawBlock": "<rawBlock>"
}
response = requests.post("https://appliance.example.com/api/v1/haproxy/acls/raw-block", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls/raw-block', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "<redirectType>",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0,
"name": "<name>",
"enabled": true,
"rawEnabled": true,
"rawBlock": "<rawBlock>"
}),
});
const data = await response.json();
Response
{
"status": "success",
"message": "Raw block generated successfully.",
"data": {
"rawBlock": "acl rule_a3f-2b9-1c4-7de_1 path_beg,url_dec -m beg -i /api /shop\nuse_backend 333-333-333-333:Shop if rule_a3f-2b9-1c4-7de_1"
}
}
By ID
curl
curl -X GET "https://appliance.example.com/api/v1/haproxy/acls/{id}" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls/{id}';
$headers = [
'Authorization: Bearer ' . $token,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
response = requests.get("https://appliance.example.com/api/v1/haproxy/acls/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls/{id}', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL retrieved successfully",
"data": {
"id": "111-111-111-111",
"name": "Route the shop to the shop backend",
"enabled": true,
"conditionSet": {
"operator": "or",
"terms": [
{
"operator": "and",
"conditionGroups": [
{
"operator": "or",
"negate": false,
"conditions": [
{
"conditionType": "path",
"condition": "eq",
"conditionValues": [
"/test.stuff",
"/cheese.com"
]
}
]
}
]
}
]
},
"redirectType": "backend",
"redirectLocation": "333-333-333-333"
}
}
curl
curl -X PUT "https://appliance.example.com/api/v1/haproxy/acls/{id}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "<name>",
"enabled": true,
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}'
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls/{id}';
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$payload = [
'name' => '<name>',
'enabled' => true,
'conditionSet' => [],
'conditionType' => '<conditionType>',
'conditionParam' => '<conditionParam>',
'conditionValues' => [
'<conditionValues>',
],
'condition' => '<condition>',
'redirectType' => 'none',
'redirectLocation' => '<redirectLocation>',
'redirectParam' => '<redirectParam>',
'redirectMatch' => '<redirectMatch>',
'captureLength' => 0,
'redirectCode' => 0,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => json_encode($payload),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
payload = {
"name": "<name>",
"enabled": true,
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}
response = requests.put("https://appliance.example.com/api/v1/haproxy/acls/{id}", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls/{id}', {
method: 'PUT',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"name": "<name>",
"enabled": true,
"conditionSet": {},
"conditionType": "<conditionType>",
"conditionParam": "<conditionParam>",
"conditionValues": [
"<conditionValues>"
],
"condition": "<condition>",
"redirectType": "none",
"redirectLocation": "<redirectLocation>",
"redirectParam": "<redirectParam>",
"redirectMatch": "<redirectMatch>",
"captureLength": 0,
"redirectCode": 0
}),
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL edited successfully",
"data": [
{
"id": "5ce68c58922d8",
"name": "Route the shop to the shop backend",
"enabled": true,
"conditionSet": {
"operator": "or",
"terms": [
{
"operator": "and",
"conditionGroups": [
{
"operator": "or",
"negate": false,
"conditions": [
{
"conditionType": "path",
"condition": "eq",
"conditionValues": [
"/shop"
]
}
]
}
]
}
]
},
"redirectType": "backend",
"redirectLocation": "333-333-333-333"
}
]
}
curl
curl -X DELETE "https://appliance.example.com/api/v1/haproxy/acls/{id}" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/acls/{id}';
$headers = [
'Authorization: Bearer ' . $token,
];
$ch = curl_init($url);
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
Python
import requests
headers = {"Authorization": f"Bearer {token}"}
response = requests.delete("https://appliance.example.com/api/v1/haproxy/acls/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/acls/{id}', {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "ACL deleted successfully",
"data": []
}