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

POST /haproxy/headers

Add HAProxy Header

This change is staged. Send PUT /services/apply to apply it.

Body parameters
type Required request | response
option Required add | delete | set | replace
name string Required

The Name of Header

value string

The Value of Header. Note:Required when option is "add"/"delete"/"set"

replace string

Replace of Header. Note:Required when option is "replace"

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

GET /haproxy/headers/hanging

Get HAProxy Headers hanging

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

GET /haproxy/headers/{id}

Get HAProxy Headers by service Id

Path parameters
id string Required

The id of the header.

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"
    }
  }
}

PUT /haproxy/headers/{id}

Edit HAProxy Header

This change is staged. Send PUT /services/apply to apply it.

Path parameters
id string Required

The id of the header.

Body parameters
type Required request | response
option Required add | delete | set | replace
name string Required

The Name of Header

value string

The Value of Header. Note:Required when option is "add"/"delete"/"set"

replace string

Replace of Header. Note:Required when option is "replace"

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"
  }
}

DELETE /haproxy/headers/{id}

Delete HAProxy Header by Id

This change is staged. Send PUT /services/apply to apply it.

Path parameters
id string Required

The id of the header.

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."
}