Detailed Description of the Problem
When using haproxy directly with PHP FPM (instead of nginx in between), haproxy adds content-length header with an incorrect (always zero) value which cannot be removed.
Some http clients refused to communicate with the API due to content-lenght being always 0 while there are some data
Expected Behavior
Either respect content-length value returned from PHP or allow me to delete the header completely. I tried http-response del-header but the header was still present in the response. When using this directive when proxying to nginx, it removes the header correctly.
Steps to Reproduce the Behavior
- Create php-fpm app with simple script
- make it return some string, make sure to set up header content-length correctly
- use haproxy to proxy traffic to fpm
- check returned headers
curl -I https://mw.myapp.eu/api/xxx
content-type: application/json; charset=utf-8
content-length: 0
....
Do you have any idea what may have caused this?
unfortunately not
Do you have an idea how to solve the issue?
unfortunately not
What is your configuration?
fcgi-app php-myapp-fpm
log-stderr global
pass-header authorization
docroot /home/domains/myapp/www
set-param SCRIPT_NAME /index.php
frontend hafrontend
....
use_backend myapp-fpm if { hdr(host) -i mw.myapp.eu }
backend myapp-fpm
use-fcgi-app php-myapp-fpm
http-response del-header content-length
server-template myapp 1 _myapp_fpm._tcp.myapp.lcl proto fcgi resolvers mydns check cookie myapp init-addr none
Output of haproxy -vv
HAProxy version 2.4.8-d1f8d41 2021/11/03 - https://haproxy.org/
Status: long-term supported branch - will stop receiving fixes around Q2 2026.
Known bugs: http://www.haproxy.org/bugs/bugs-2.4.8.html
Running on: Linux 4.19.0-17-amd64 #1 SMP Debian 4.19.194-3 (2021-07-18) x86_64
Build options :
TARGET = linux-musl
CPU = generic
CC = cc
CFLAGS = -O2 -g -Wall -Wextra -Wdeclaration-after-statement -fwrapv -Wno-address-of-packed-member -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-clobbered -Wno-missing-field-initializers -Wno-cast-function-type -Wtype-limits -Wshift-negative-value -Wshift-overflow=2 -Wduplicated-cond -Wnull-dereference
OPTIONS = USE_PCRE=1 USE_OPENSSL=1 USE_LUA=1 USE_ZLIB=1 USE_NS=1 USE_PROMEX=1
DEBUG =
Feature list : +EPOLL -KQUEUE +NETFILTER +PCRE -PCRE_JIT -PCRE2 -PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED -BACKTRACE -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H +GETADDRINFO +OPENSSL +LUA +FUTEX +ACCEPT4 -CLOSEFROM +ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL -SYSTEMD -OBSOLETE_LINKER +PRCTL -PROCCTL +THREAD_DUMP -EVPORTS -OT -QUIC +PROMEX -MEMORY_PROFILING
Default settings :
bufsize = 16384, maxrewrite = 1024, maxpollevents = 200
Built with multi-threading support (MAX_THREADS=64, default=64).
Built with OpenSSL version : OpenSSL 1.1.1l 24 Aug 2021
Running on OpenSSL version : OpenSSL 1.1.1l 24 Aug 2021
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : TLSv1.0 TLSv1.1 TLSv1.2 TLSv1.3
Built with Lua version : Lua 5.4.3
Built with the Prometheus exporter as a service
Built with network namespace support.
Built with zlib version : 1.2.11
Running on zlib version : 1.2.11
Compression algorithms supported : identity("identity"), deflate("deflate"), raw-deflate("deflate"), gzip("gzip")
Built with transparent proxy support using: IP_TRANSPARENT IPV6_TRANSPARENT IP_FREEBIND
Built with PCRE version : 8.45 2021-06-15
Running on PCRE version : 8.45 2021-06-15
PCRE library supports JIT : no (USE_PCRE_JIT not set)
Encrypted password support via crypt(3): yes
Built with gcc compiler version 10.3.1 20211027
Available polling systems :
epoll : pref=300, test result OK
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 3 (3 usable), will use epoll.
Available multiplexer protocols :
(protocols marked as <default> cannot be specified using 'proto' keyword)
h2 : mode=HTTP side=FE|BE mux=H2 flags=HTX|CLEAN_ABRT|HOL_RISK|NO_UPG
fcgi : mode=HTTP side=BE mux=FCGI flags=HTX|HOL_RISK|NO_UPG
<default> : mode=HTTP side=FE|BE mux=H1 flags=HTX
h1 : mode=HTTP side=FE|BE mux=H1 flags=HTX|NO_UPG
<default> : mode=TCP side=FE|BE mux=PASS flags=
none : mode=TCP side=FE|BE mux=PASS flags=NO_UPG
Available services : prometheus-exporter
Available filters :
[SPOE] spoe
[CACHE] cache
[FCGI] fcgi-app
[COMP] compression
[TRACE] trace
Last Outputs and Backtraces
No response
Additional Information
No response
Detailed Description of the Problem
When using haproxy directly with PHP FPM (instead of nginx in between), haproxy adds
content-lengthheader with an incorrect (always zero) value which cannot be removed.Some http clients refused to communicate with the API due to content-lenght being always 0 while there are some data
Expected Behavior
Either respect
content-lengthvalue returned from PHP or allow me to delete the header completely. I triedhttp-response del-headerbut the header was still present in the response. When using this directive when proxying to nginx, it removes the header correctly.Steps to Reproduce the Behavior
Do you have any idea what may have caused this?
unfortunately not
Do you have an idea how to solve the issue?
unfortunately not
What is your configuration?
Output of
haproxy -vvLast Outputs and Backtraces
No response
Additional Information
No response