Ana içeriğe atla

Endpoint

PATCH /apiops/projects/{projectName}/apiProxies/{apiProxyName}/settings/forwarded-ip-header/

Authentication

Requires a Personal API Access Token.
Authorization: Bearer YOUR_TOKEN

Request

Headers

HeaderValueRequired
AuthorizationBearer Yes
Content-Typeapplication/jsonYes

Path Parameters

ParameterTypeRequiredDescription
projectNamestringYesProject name
apiProxyNamestringYesAPI Proxy name

Request Body

Full JSON Body Example

{
  "forwardedIpHeaderParamActive": true,
  "value": "X-Forwarded-For",
  "xffOrder": "FIRST"
}

Request Body Fields

FieldTypeRequiredDefaultDescription
forwardedIpHeaderParamActivebooleanNofalseEnable/disable forwarded IP header
valuestringNoX-Forwarded-ForHeader name to use for forwarded IP
xffOrderstringNoFIRSTOrder of IP address in X-Forwarded-For header

EnumPolicyXFFOrder

  • FIRST - Use first IP address in X-Forwarded-For header
  • SECOND - Use second IP address in X-Forwarded-For header
  • THIRD - Use third IP address in X-Forwarded-For header
  • FOURTH - Use fourth IP address in X-Forwarded-For header
  • FIFTH - Use fifth IP address in X-Forwarded-For header
  • LAST - Use last IP address in X-Forwarded-For header
Note: All fields are optional. Only provided fields are updated.

X-Forwarded-For Header

The X-Forwarded-For header contains a comma-separated list of IP addresses:
X-Forwarded-For: client-ip, proxy1-ip, proxy2-ip
The xffOrder determines which IP address is used:
  • FIRST - Uses client-ip (original client)
  • LAST - Uses proxy2-ip (last proxy)
  • SECOND, THIRD, etc. - Uses IP at specified position

Response

Success Response (200 OK)

{
  "success": true
}

Response Fields

FieldTypeDescription
successbooleanIndicates if the request was successful

Error Response (400 Bad Request)

{
  "error": "bad_request",
  "error_description": "Invalid forwarded IP header settings"
}

Error Response (401 Unauthorized)

{
  "error": "unauthorized_client",
  "error_description": "Invalid token"
}

Error Response (404 Not Found)

{
  "error": "not_found",
  "error_description": "ApiProxy (name: MyAPI) was not found!"
}

cURL Example

Example 1: Enable Forwarded IP Header

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/forwarded-ip-header/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "forwardedIpHeaderParamActive": true,
    "value": "X-Forwarded-For",
    "xffOrder": "FIRST"
  }'

Example 2: Use Custom Header Name

curl -X PATCH \
  "https://demo.apinizer.com/apiops/projects/MyProject/apiProxies/MyAPI/settings/forwarded-ip-header/" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "forwardedIpHeaderParamActive": true,
    "value": "X-Real-IP",
    "xffOrder": "LAST"
  }'

Notes and Warnings

  • Header Name: Default is X-Forwarded-For. Can be customized (e.g., X-Real-IP)
  • IP Order: FIRST gets original client IP, LAST gets last proxy IP
  • Use Cases:
    • Forward client IP for logging/analytics
    • Forward client IP for rate limiting
    • Forward client IP for geolocation
  • Chain: X-Forwarded-For contains comma-separated IP chain

Permissions

User must have API_MANAGEMENT + MANAGE permission in the project.