Headers
Header rules add, remove or rewrite HTTP headers on requests and responses passing through a Layer 7 service.
Create a Layer 7 header rule
curl
curl -X POST "https://appliance.example.com/api/v1/haproxy/headers" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}'
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/headers';
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$payload = [
'type' => 'request',
'option' => 'add',
'name' => '<name>',
'value' => '<value>',
'replace' => '<replace>',
];
$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 = {
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}
response = requests.post("https://appliance.example.com/api/v1/haproxy/headers", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/headers', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}),
});
const data = await response.json();
Response
{
"status": "success",
"message": "Header added successfully",
"data": {
"id": "5f9-006-e7b-26c"
}
}
List the Layer 7 header rules with pending changes
curl
curl -X GET "https://appliance.example.com/api/v1/haproxy/headers/hanging" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/headers/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/headers/hanging", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/headers/hanging', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "Hanging header retrieved successfully",
"data": {
"5f9-006-e7b-26c": {
"type": "request",
"option": "add",
"name": "X-Forwarded-For",
"value": "192.168.68.1",
"id": "5f9-006-e7b-26c"
}
}
}
By ID
curl
curl -X GET "https://appliance.example.com/api/v1/haproxy/headers/{id}" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/headers/{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/headers/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/headers/{id}', {
method: 'GET',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "Header retrieved successfully",
"data": {
"5f9006e7b26c4": {
"type": "request",
"option": "add",
"name": "X-Forwarded-For",
"value": "192.168.68.1",
"id": "5f9006e7b26c4"
}
}
}
curl
curl -X PUT "https://appliance.example.com/api/v1/haproxy/headers/{id}" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}'
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/headers/{id}';
$headers = [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
];
$payload = [
'type' => 'request',
'option' => 'add',
'name' => '<name>',
'value' => '<value>',
'replace' => '<replace>',
];
$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 = {
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}
response = requests.put("https://appliance.example.com/api/v1/haproxy/headers/{id}", headers=headers, json=payload)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/headers/{id}', {
method: 'PUT',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"type": "request",
"option": "add",
"name": "<name>",
"value": "<value>",
"replace": "<replace>"
}),
});
const data = await response.json();
Response
{
"status": "success",
"message": "Header edited successfully",
"data": {
"id": "5f9-006-e7b-26c"
}
}
curl
curl -X DELETE "https://appliance.example.com/api/v1/haproxy/headers/{id}" \
-H "Authorization: Bearer $TOKEN"
PHP
<?php
$url = 'https://appliance.example.com/api/v1/haproxy/headers/{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/headers/{id}", headers=headers)
response.raise_for_status()
print(response.json())
JavaScript
const response = await fetch('https://appliance.example.com/api/v1/haproxy/headers/{id}', {
method: 'DELETE',
headers: {
Authorization: `Bearer ${token}`,
},
});
const data = await response.json();
Response
{
"status": "success",
"message": "Header deleted successfully."
}