fbpx
POSThttps://api.spotinst.io/loadBalancer/middleware?accountId={ACCOUNT_ID}

Create a new middleware

URL Parameters

Parameter Type Description
ACCOUNT_ID String

Account ID from Spotinst console

Example: act-12345
Request

Headers
{
  "Content-Type": "application/json",
  "Authorization": "Bearer ${token}"
}
Body
Copied!
Downloaded!
{
  "middleware": {
    "balancerId": "lb-6acf2ff362ac",
    "type": "ACL",
    "priority": 1,
    "spec": {
      "action": "ALLOW",
      "conditions": [
        {
          "type": "HTTP_REQUEST_IP",
          "values": [
            "1.2.3.4",
            "1.2.3.5"
          ]
        }
      ]
    },
    "tags": [
      {
        "key": "Environment",
        "value": "Production"
      }
    ]
  }
}

Body Attributes


  • middleware.balancerId * String
    The id of the balancer
  • middleware.priority * Integer
    The priority of the Middleware on the RoutingRule middleware chain.
  • middleware.type * String
    Middleware type can be one of the following:

    ACL:
    An Access Control List (ACL) is a security enhancement available for Multai Load Balancer. An ACL provides the ability to selectively permit, deny or limit traffic for Balancer’s Routing Rule.

    LUA:
    Lua is a powerful and fast programming language that is easy to learn and use and to embed into your Balancer. Lua is designed to be a lightweight embeddable scripting language. It is used for all sorts of applications, from games to web applications and image processing
  • middleware.spec * String
    The spec of the Middleware. The spec should be according to the middleware type as follow:

    ACL:

    “spec”:{
    “action”: “ALLOW/DENY”,
    “conditions”: [
    { “type”: “HTTP_REQUEST_IP/HTTP_REQUEST_HEADER/HTTP_REQUEST_METHOD/HTTP_REQUEST_COOKIE”,
    “values”: [
    “1.2.3.5”/“username=John Doe”/“POST”/ ] } ] }

    LUA:
    “spec”:{
    “name”:“Lua Hello World”,
    “code”:“cHJpbnQoJ2hlbGxvLXdvcmxkJyk=”,
    //Base64 “timeout”:60
    //Timeout in seconds (optional) }
  • middleware.tags.key String
    The tag’s key
  • middleware.tags.value String
    The tag’s value
Response - 200

Headers
{
  "Content-Type": "application/json"
}
Body
Copied!
Downloaded!
{
  "status": {
    "code": 200,
    "message": "OK"
  },
  "kind": "spotinst:lb:middleware",
  "items": [
    {
      "id": "mw-d13133e1eab0",
      "balancerId": "lb-57e0dad0627c",
      "type": "ACL",
      "priority": 1,
      "spec": {
        "action": "ALLOW",
        "conditions": [
          {
            "type": "HTTP_REQUEST_IP",
            "values": [
              "1.2.3.4",
              "1.2.3.5"
            ]
          }
        ]
      },
      "tags": [
        {
          "key": "Environment",
          "value": "Production"
        }
      ]
    }
  ],
  "count": 1
}