1---
2c: Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
3SPDX-License-Identifier: curl
4Title: CURLOPT_HAPROXY_CLIENT_IP
5Section: 3
6Source: libcurl
7Protocol:
8  - All
9See-also:
10  - CURLOPT_HAPROXYPROTOCOL (3)
11  - CURLOPT_PROXY (3)
12Added-in: 8.2.0
13---
14
15# NAME
16
17CURLOPT_HAPROXY_CLIENT_IP - set HAProxy PROXY protocol client IP
18
19# SYNOPSIS
20
21~~~c
22#include <curl/curl.h>
23
24CURLcode curl_easy_setopt(CURL *handle, CURLOPT_HAPROXY_CLIENT_IP,
25                          char *client_ip);
26~~~
27
28# DESCRIPTION
29
30When this parameter is set to a valid IPv4 or IPv6 numerical address, the
31library sends this address as client address in the HAProxy PROXY protocol v1
32header at beginning of the connection.
33
34This option is an alternative to CURLOPT_HAPROXYPROTOCOL(3) as that one cannot
35use a specified address.
36
37Using this option multiple times makes the last set string override the
38previous ones. Set it to NULL to disable its use again.
39
40The application does not have to keep the string around after setting this
41option.
42
43# DEFAULT
44
45NULL, no HAProxy header is sent
46
47# %PROTOCOLS%
48
49# EXAMPLE
50
51~~~c
52int main(void)
53{
54  CURL *curl = curl_easy_init();
55  if(curl) {
56    CURLcode ret;
57    curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
58    curl_easy_setopt(curl, CURLOPT_HAPROXY_CLIENT_IP, "1.1.1.1");
59    ret = curl_easy_perform(curl);
60  }
61}
62~~~
63
64# %AVAILABILITY%
65
66# RETURN VALUE
67
68Returns CURLE_OK if HTTP is enabled, and CURLE_UNKNOWN_OPTION if not.
69