### Starting HAProxy with Options Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html The basic syntax for starting the HAProxy executable with command-line options. Options typically start with '-' followed by letters and optional arguments. ```bash $ haproxy [\\ ]* ``` -------------------------------- ### Master CLI Configuration with Unix Socket and Permissions Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example demonstrates starting HAProxy with the master CLI bound to a Unix domain socket, specifying user ID, group ID, and file mode for access control. ```bash # haproxy -Ws -S /tmp/master-socket,uid,1000,gid,1000,mode,600 -f test1.cfg ``` -------------------------------- ### Master CLI Configuration with TCP Socket Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example shows how to start HAProxy in master-worker mode and configure the master CLI to listen on a TCP socket with specific bind options. ```bash # haproxy -W -S 127.0.0.1:1234 -f test1.cfg ``` -------------------------------- ### Set Bandwidth Limit Example 1 Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example of setting a global bandwidth limit. ```haproxy http-request set-bandwidth-limit global-limit ``` -------------------------------- ### Start Trace Immediately Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Immediately starts the trace for the current source. The keyword 'now' triggers the action without an event. ```bash start now ``` -------------------------------- ### Accept GET and HEAD requests using method ACL Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This example demonstrates how to define an ACL to filter for specific HTTP methods (GET and HEAD) and then deny requests that do not match. ```haproxy acl valid_method method GET HEAD http-request deny if ! valid_method ``` -------------------------------- ### Logging Configuration Examples Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Examples of configuring the 'log' directive for different destinations and formats, including systemd, stdout, stderr, and syslog over UDP/TCP. ```haproxy-config log global log stdout format short daemon # send log to systemd log stdout format raw daemon # send everything to stdout log stderr format raw daemon notice # send important events to stderr log 127.0.0.1:514 local0 notice # only send important events log tcp@127.0.0.1:514 local0 notice notice # same but limit output # level and send in tcp log "${LOCAL_SYSLOG}:514" local0 notice # send to local server ``` -------------------------------- ### Example HAProxy TCP Configuration Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html A sample HAProxy frontend and backend configuration demonstrating the 'option tcplog' setting. This setup is typical for TCP proxying and logging. ```haproxy frontend fnt mode tcp option tcplog log global default_backend bck backend bck server srv1 127.0.0.1:8000 ``` -------------------------------- ### Enable Start Event Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Enables a specific event to automatically start the trace. Use '+' to enable, '-' or '!' to disable. ```bash start +event_name ``` -------------------------------- ### HTTP Request Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example of a basic HTTP GET request with headers. This illustrates the structure of an HTTP request as processed by HAProxy. ```http GET /serv/login.php?lang=en&profile=2 HTTP/1.1 Host: www.mydomain.com User-agent: my small browser Accept: image/jpeg, image/gif Accept: image/png ``` -------------------------------- ### HTTP Logging Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example HAProxy configuration snippet demonstrating HTTP logging options and server configuration. ```haproxy-config listen proxy-out mode http option httplog option logasap log global server cache1 192.168.1.1:3128 ``` -------------------------------- ### Set Bandwidth Limit Example 2 Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example of setting a custom bandwidth limit and period for a specific filter. ```haproxy http-request set-bandwidth-limit my-limit limit 1m period 10s ``` -------------------------------- ### Server State File Content Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example content of a server state file generated by 'show servers state'. This format is used by HAProxy to restore server states across reloads. ```text 1 # 1 bk 1 s1 127.0.0.1 2 0 11 11 4 6 3 4 6 0 0 1 bk 2 s2 127.0.0.1 2 0 12 12 4 6 3 4 6 0 0 ``` -------------------------------- ### List Start Events Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Lists events that automatically start a trace for the current source. Events can be enabled or disabled. ```bash start ``` -------------------------------- ### HTTP Frontend Configuration Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html A sample HAProxy frontend configuration demonstrating how to enable HTTP logging and define backend servers. ```haproxy frontend http-in mode http option httplog log global default_backend bck backend static server srv1 127.0.0.1:8000 ``` -------------------------------- ### Start Trace with Specific Events Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Initiates a trace on source 'h1' starting with 'lock', pausing at 'session start', resuming at 'sess_new', pausing again at 'sess_end', and following 'session' events. ```bash trace h1 lock session start sess_new pause sess_end follow session ``` -------------------------------- ### Log Format with Quoting and Request Details Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example demonstrating the use of the 'Q' flag for quoting and logging request details. ```haproxy log-format %{+Q}o\ %t\ %s\ %{-Q}r ``` -------------------------------- ### Start HAProxy in Daemon Mode with PID File Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This command starts HAProxy in daemon mode, writes its PID to a file, and signals older processes to terminate gracefully before exiting. It's a safe way to start HAProxy from an init script. ```bash haproxy -f /etc/haproxy.cfg \ -D -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) ``` -------------------------------- ### Example: Passing X-Proto Header for SSL Connections Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This example demonstrates how to pass an 'X-Proto: https' header to servers when a client connects over SSL. It configures HAProxy to listen on both HTTP and HTTPS ports, with SSL enabled for the HTTPS port. ```haproxy listen http-https bind :80 bind :443 ssl crt /etc/haproxy.pem ``` -------------------------------- ### Example HAProxy Frontend and Backend Configuration for HTTPS Logging Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html A sample HAProxy configuration demonstrating how to set up a frontend for HTTPS traffic with logging enabled and a backend server. This configuration is used to generate the example log entry. ```haproxy frontend https-in mode http option httpslog log global bind *:443 ssl crt mycerts/srv.pem ... default_backend bck backend static server srv1 127.0.0.1:8000 ssl crt mycerts/clt.pem ... ``` -------------------------------- ### HAProxy Log Entry Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example of a detailed log entry from HAProxy, showing connection and request information. ```log haproxy[18989]: 10.0.0.1:34552 [15/Oct/2003:15:26:31.462] px-http \ px-http/srv1 3183/-1/-1/-1/11215 503 0 - - SC-- 205/202/202/115/3 \ 0/0 "HEAD / HTTP/1.0" ``` -------------------------------- ### Basic Log Format Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html A simple log format using timestamp and text. ```haproxy log-format %T\ %t\ Some\ Text ``` -------------------------------- ### HAProxy Reload Command Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Initiates a reload of the HAProxy master process using socat, demonstrating a successful reload. ```bash $ echo "reload" | socat -t300 /var/run/haproxy-master.sock stdin ``` -------------------------------- ### Configure Statistics with Description Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example of enabling statistics for a backend and adding a custom description to the statistics page. ```haproxy backend private_monitoring stats enable stats show-desc Master node for Europe, Asia, Africa stats uri /admin?stats stats refresh 5s ``` -------------------------------- ### HAProxy Backend Server Configuration Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Example backend configuration for a primary server, defining multiple server instances. ```haproxy backend server server cache1 "${SERVER_PFX}.1:8080" check server cache2 "${SERVER_PFX}.2:8080" check ``` -------------------------------- ### Server Configuration Examples Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Illustrates different ways to configure servers, including IP addresses, ports, environment variables, and backup servers. ```haproxy server first 10.1.1.1:1080 cookie first check inter 1000 server second 10.1.1.2:1080 cookie second check inter 1000 ``` ```haproxy server transp ipv4@ ``` ```haproxy server backup "${SRV_BACKUP}:1080" backup ``` ```haproxy server www1_dc1 "${LAN_DC1}.101:80" server www1_dc2 "${LAN_DC2}.101:80" ``` -------------------------------- ### Load Customer-Specific Configuration Files Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example shows how to load an unknown number of customer-specific configuration files by using a wildcard after the '--' option. It's useful for managing dynamic or numerous configuration files. ```bash haproxy -f /etc/haproxy/global.cfg -f /etc/haproxy/stats.cfg \ -f /etc/haproxy/default-tcp.cfg -f /etc/haproxy/tcp.cfg \ -f /etc/haproxy/default-http.cfg -f /etc/haproxy/http.cfg \ -D -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) \ -f /etc/haproxy/default-customers.cfg -- /etc/haproxy/customers/ ``` -------------------------------- ### Example HAProxy Log Entry - HTTP Request Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example HAProxy log entry for a standard HTTP GET request, detailing connection information, response time, and request details. ```log >>> Aug 9 20:30:46 localhost \ haproxy[2022]: 127.0.0.1:34020 [09/Aug/2004:20:30:46] proxy-out \ proxy-out/cache1 0/0/0/182/+182 200 +279 - - ---- 0/0/0/0/0 0/0 \ {w.ods.org||} {Formilux/0.1.8|3495|||} \ "GET http://trafic.1wt.eu/ HTTP/1.1" ``` -------------------------------- ### Get HTTP Request Rate Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Returns the average rate of HTTP requests from tracked counters over a configured period. This includes every started request. ```haproxy sc_http_req_rate([,]) ``` ```haproxy sc0_http_req_rate([
]) ``` ```haproxy sc1_http_req_rate([
]) ``` ```haproxy sc2_http_req_rate([
]) ``` -------------------------------- ### Master CLI Prompt Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Demonstrates how to interact with the HAProxy master CLI, enabling various modes like expert, experimental, and debug, and observing the prompt changes. ```bash $ socat /var/run/haproxy-master.sock - prompt master> expert-mode on master(e)> experimental-mode on master(xe)> mcli-debug-mode on master(xed)> @1 95191(xed)> ``` -------------------------------- ### Get HTTP Request Count Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Returns the cumulative number of HTTP requests from tracked counters. This counts every started request, regardless of validity. ```haproxy sc_http_req_cnt([,
]) ``` ```haproxy sc0_http_req_cnt([
]) ``` ```haproxy sc1_http_req_cnt([
]) ``` ```haproxy sc2_http_req_cnt([
]) ``` -------------------------------- ### Experimental Navigation - Setup Source: https://github.com/haproxy/docs/blob/master/docs/3.4/intro.html Sets up experimental previous/next navigation for the document. It finds all headings, tracks the current and next target based on scroll position, and updates navigation links. ```javascript /* EXPERIMENTAL - Previous/Next navigation */ var headings = $(":header") var previousTarget = false var nextTarget = false var $previous = $("#previous") var $next = $("#next") function refreshNavigation() { var previous = false var next = false $.each(headings, function(item, value) { var el = $(value) // TODO : avoid target recalculation on each refresh var target = el.attr('data-target') if (! target) return true var target_el = $("#" + target.replace(/\./, "\\.")) if (! target_el.attr('id')) return true if (target_el.offset().top < $(window).scrollTop()) { previous = el } if (target_el.offset().top - 1 > $(window).scrollTop()) { next = el } if (next) return false }) previousTarget = previous ? previous.attr('data-target') : 'top' nextTarget = next ? next.attr('data-target') : 'bottom' } $(window).scroll(function () { refreshNavigation() }); $(document).ready(function() { refreshNavigation() }); ``` -------------------------------- ### Get Process-Wide Variable Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Retrieves the existence, type, and content of a process-wide variable. The variable name must start with 'proc.' and requires operator or admin level access. ```bash get var ``` -------------------------------- ### Define HTTP Health Check Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Creates a named health check of type httpchk. This example uses a GET request to a /health endpoint and includes the server name in the request. ```haproxy healthcheck my-http-check type httpchk GET /health HTTP/1.1 %[srv_name] ``` -------------------------------- ### Extract Binary Payload from Response Buffer Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This example shows how to extract a binary block of a specified length starting at a given offset from the response buffer. This is useful for detailed inspection of response content. ```haproxy res.payload(,) : binary ``` -------------------------------- ### Master CLI Configuration with Unix Socket and User Level Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example shows how to configure the master CLI to bind to a Unix domain socket with a specified user access level. ```bash # haproxy -W -S /tmp/master-socket,level,user -f test1.cfg ``` -------------------------------- ### Set X-Cert-Name Header based on SSL Certificate Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This example demonstrates how to set an HTTP request header 'X-Cert-Name' with the name of the SSL certificate used for the incoming connection. It uses an ACL to match certificates starting with a specific path. ```haproxy crt-store example load crt "example.com.pem" frontend www bind *:443 ssl crt "@example/example.com.pem" acl match_certificate ssl_fc_crtname -m beg -i "@example/" http-request set-header X-Cert-Name %[ssl_fc_crtname] if match_certificate ``` -------------------------------- ### Basic TCP and UNIX Socket Bindings Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Demonstrates binding to standard ports, multiple IP addresses, and UNIX domain sockets. The UNIX socket example shows how to set user, mode, and accept-proxy options. ```haproxy listen http_proxy bind :80,:443 bind 10.0.0.1:10080,10.0.0.1:10443 bind /var/run/ssl-frontend.sock user root mode 600 accept-proxy ``` -------------------------------- ### Configure Redirection Mode Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Enables redirection mode for GET and HEAD requests, sending an HTTP 302 response with a 'Location' header. Use this to direct users to a remote location, for example, to increase bandwidth for static servers by having clients connect directly to them. Do not use a relative location, as it would cause a loop. ```haproxy server srv1 192.168.1.1:80 redir http://image1.mydomain.com check ``` -------------------------------- ### Launch HTTP Client Request Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Initiates an HTTP client request and displays the response. This command is intended for debugging and requires the CLI to be in expert mode. ```bash httpclient [--htx] ``` -------------------------------- ### Configure Certificate and Key Base Directories Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This snippet illustrates setting base directories for certificate and key files within a specific `crt-store` instance, allowing for relative path loading. ```haproxy crt-store web crt-base /etc/ssl/certs/ key-base /etc/ssl/private/ load crt "site3.crt" alias "site3" load crt "site4.crt" key "site4.key" ``` -------------------------------- ### Load Multiple Configuration Files Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This command demonstrates loading HAProxy configuration from multiple files, which is recommended when the configuration is split into specific parts. It also includes daemon mode and PID file management. ```bash haproxy -f /etc/haproxy/global.cfg -f /etc/haproxy/stats.cfg \ -f /etc/haproxy/default-tcp.cfg -f /etc/haproxy/tcp.cfg \ -f /etc/haproxy/default-http.cfg -f /etc/haproxy/http.cfg \ -D -p /var/run/haproxy.pid -sf $(cat /var/run/haproxy.pid) ``` -------------------------------- ### Get Help for Commands Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Displays a list of available keywords and their usage, or specific help for a requested command. Useful for discovering and understanding available CLI commands. ```bash help [] ``` -------------------------------- ### Example HTTPS Log Entry Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html A concrete example of a log entry generated using the HTTPS log format, illustrating the detailed information captured for SSL connections. ```log >>> Feb 6 12:14:14 localhost \ haproxy[14389]: 10.0.1.2:33317 [06/Feb/2009:12:14:14.655] https-in \ static/srv1 10/0/30/69/109 200 2750 - - ---- 1/1/1/1/0 0/0 {1wt.eu} \ {} "GET /index.html HTTP/1.1" 0/0/0/0/0 \ 1wt.eu/TLSv1.3/TLS_AES_256_GCM_SHA384 ``` -------------------------------- ### Basic socat Command with Wait Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html A simple example showing how to use socat to send commands to HAProxy, including a 'wait' command with a specified duration. ```bash $ socat -t20 /path/to/socket - <<< "show activity; wait 10s; show activity" ``` -------------------------------- ### HAProxy Default Log Format Configuration Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This snippet shows the configuration for a HAProxy listener that uses the default log format. The log message example demonstrates the output of this format. ```haproxy listen www mode http log global server srv1 127.0.0.1:8000 ``` ```log >>> Feb 6 12:12:09 localhost \ haproxy[14385]: Connect from 10.0.1.2:33312 to 10.0.3.31:8012 \ (www/HTTP) ``` -------------------------------- ### Example HAProxy Log Entry - Redirected Request Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example HAProxy log entry for a request that resulted in a redirect (301 status code), showing client IP, timestamp, and the requested URL. ```log >>> Aug 9 20:30:46 localhost \ haproxy[2022]: 127.0.0.1:34028 [09/Aug/2004:20:30:46] proxy-out \ proxy-out/cache1 0/0/2/126/+128 301 +223 - - ---- 0/0/0/0/0 0/0 \ {www.sytadin.equipement.gouv.fr||http://trafic.1wt.eu/} \ {Apache|230|||http://www.sytadin.} \ "GET http://www.sytadin.equipement.gouv.fr/ HTTP/1.1" ``` -------------------------------- ### Dump Statistics via socat Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example demonstrates how to issue multiple commands to HAProxy via socat and retrieve statistics. It shows the typical output format for both info and stats. ```bash $ echo "show info;show stat" | socat stdio unix-connect:/tmp/sock1 >>> Name: HAProxy Version: 1.4-dev2-49 Release_date: 2009/09/23 Nbproc: 1 Process_num: 1 (...) # pxname,svname,qcur,qmax,scur,smax,slim,stot,bin,bout,dreq, (...) stats,FRONTEND,,,0,0,1000,0,0,0,0,0,0,,,,,OPEN,,,,,,,,,1,1,0, (...) stats,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,0,0,0,,0,250,(_...) www1,BACKEND,0,0,0,0,1000,0,0,0,0,0,,0,0,0,0,UP,1,1,0,,0,250, ( ...) $ ``` -------------------------------- ### HAProxy Example: Rate Limiting with Counters Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html This example demonstrates how to use counters to implement rate limiting. It blocks requests if a certain rate is exceeded for a consecutive period and resets the counter when traffic slows down. ```haproxy acl abuse sc0_http_req_rate gt 10 a cl kill sc0_inc_gpc0 gt 5 a cl save sc0_clr_gpc0 ge 0 tcp-request connection accept if !abuse save tcp-request connection reject if abuse kill ``` -------------------------------- ### HAProxy Master CLI Output Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This snippet shows the expected output format for the 'show proc' command on the HAProxy Master CLI, detailing process information like PID, type, reloads, uptime, and version. ```text Success=0 -- [NOTICE] (482886) : haproxy version is 2.7-dev7-4827fb-69 [NOTICE] (482886) : path to executable is ./haproxy [ALERT] (482886) : config : parsing [test3.cfg:1]: unknown keyword 'Aglobal' out of section. [ALERT] (482886) : config : Fatal errors found in configuration. [WARNING] (482886) : Loading failure! $ ``` -------------------------------- ### Example HAProxy Log Entry - POST Data Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html An example of an HAProxy log entry showing details of a POST request, including client IP, timestamp, proxy information, status code, and captured headers. ```log >>> Aug 9 20:26:09 localhost \ haproxy[2022]: 127.0.0.1:34014 [09/Aug/2004:20:26:09] proxy-out \ proxy-out/cache1 0/0/0/162/+162 200 +350 - - ---- 0/0/0/0/0 0/0 \ {fr.adserver.yahoo.co||http://fr.f416.mail.} {|864|private||} \ "GET http://fr.adserver.yahoo.com/" ``` -------------------------------- ### Typical HAProxy Configuration Structure Source: https://github.com/haproxy/docs/blob/master/_autodocs/configuration-sections.md Illustrates a common HAProxy configuration pattern, combining global, defaults, frontend, and backend sections. ```haproxy # Global settings apply to the entire HAProxy instance global maxconn 4096 daemon # Defaults apply to all following proxies until next defaults section defaults mode http timeout connect 5000 timeout client 50000 # Frontend listens for client connections frontend www-http bind 0.0.0.0:80 default-backend www-backend # Backend servers to receive connections backend www-backend balance roundrobin server web1 192.168.1.1:8080 check server web2 192.168.1.2:8080 check ``` -------------------------------- ### HAProxy Idle Process Activity Example Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html This example shows the typical output of strace for an idle HAProxy process, illustrating periodic calls to epoll_wait and gettimeofday for internal clock management. This is normal behavior and indicates no performance issues. ```text 16:35:40.002320 gettimeofday({1442759740, 2605}, NULL) = 0 16:35:40.002942 epoll_wait(0, {}, 200, 1000) = 0 ``` -------------------------------- ### Bind with SSL Certificate Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Example of binding to a port with an SSL certificate. ```haproxy-config bind :443 ssl crt foobar.pem ``` -------------------------------- ### Environment Variables for HAProxy Configuration Source: https://github.com/haproxy/docs/blob/master/docs/3.4/management.html Demonstrates how to define environment variables in a separate file and then use them within the HAProxy configuration file. This allows for flexible and shared configurations. ```bash $ cat site1.env LISTEN=192.168.1.1 CACHE_PFX=192.168.11 SERVER_PFX=192.168.22 LOGGER=192.168.33.1 STATSLP=admin:pa$$w0rd ABUSERS=/etc/haproxy/abuse.lst TIMEOUT=10s $ cat haproxy.cfg global log "${LOGGER}:514" local0 defaults mode http ``` -------------------------------- ### hdr_cnt (deprecated) Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Deprecated function to get the count of header occurrences. ```APIDOC ## hdr_cnt (deprecated) ### Description Deprecated function that returns an integer value representing the number of occurrences of request header field name , or the total number of header field values if is not specified. Like req.hdr() it counts each comma separated part of the header's value. If counting of full-line headers is desired, then req.fhdr_cnt() should be used instead. ### Method N/A (Function within HAProxy configuration) ### Parameters #### Path Parameters - **header** (string) - Optional - The name of the header field to count. ### Response #### Success Response - **integer** - The number of occurrences of the specified header field. ``` -------------------------------- ### Example: Forwarded Header with Proto and For Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Illustrates a backend configuration where the 'option forwarded' directive is used with 'proto' and 'for' enabled, resulting in a forwarded header like 'proto=http;for=127.0.0.1'. ```haproxy-config backend www_default option forwarded proto for ``` -------------------------------- ### cook_cnt (deprecated) Source: https://github.com/haproxy/docs/blob/master/docs/3.4/configuration.html Deprecated function to get the count of cookie occurrences. ```APIDOC ## cook_cnt (deprecated) ### Description Deprecated function that returns an integer value representing the number of occurrences of the cookie in the request, or all cookies if is not specified. ### Method N/A (Function within HAProxy configuration) ### Parameters #### Path Parameters - **name** (string) - Optional - The name of the cookie to count. ### Response #### Success Response - **integer** - The count of the specified cookie occurrences. ```