HAProxy community

Http-request set-path not working

I am using haproxy version 2.0.6. Following are the relevant front and back ends:

frontend test
mode http
option httplog
option http-buffer-request
acl receipt req.body -m reg data
use_backend receipt_back if receipt
default_backend prod

backend receipt_back
http-request set-path /app2/receipt.jsp <------------------
mode http
balance roundrobin
option forwardfor
server SERVER-1 ssl verify none check

Everything is working fine but the line http-request set-path /app2/receipt.jsp is not working. The default URL is /app1/receipt.jsp and logs are showing that although the backend selected is receipt_back, the URL is still /app1/receipt.jsp

Output of haproxy -vv:
HA-Proxy version 2.0.6 2019/09/13 - https://haproxy.org/
Build options :
TARGET = linux-generic
CPU = generic
CC = gcc
CFLAGS = -O2 -g -fno-strict-aliasing -DTCP_USER_TIMEOUT=18


Default settings :
bufsize = 16384, maxrewrite = 1024, maxpollevents = 200

Built with multi-threading support (MAX_THREADS=64, default=64).
Built with OpenSSL version : LibreSSL 2.9.2
Running on OpenSSL version : LibreSSL 2.9.2
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : TLSv1.0 TLSv1.1 TLSv1.2
Built with transparent proxy support using: IP_TRANSPARENT IP_FREEBIND
Built with zlib version : 1.2.7
Running on zlib version : 1.2.7
Compression algorithms supported : identity(“identity”), deflate(“deflate”), raw-deflate(“deflate”), gzip(“gzip”)
Built with PCRE2 version : 10.32 2018-09-10
PCRE2 library supports JIT : yes
Encrypted password support via crypt(3): yes

Available polling systems :
poll : pref=200, test result OK
select : pref=150, test result OK
Total: 2 (2 usable), will use poll.

Available multiplexer protocols :
(protocols marked as cannot be specified using ‘proto’ keyword)
h2 : mode=HTX side=FE|BE mux=H2
h2 : mode=HTTP side=FE mux=H2
: mode=HTX side=FE|BE mux=H1
: mode=TCP|HTTP side=FE|BE mux=PASS

Available services : none

Available filters :
[SPOE] spoe
[COMP] compression
[CACHE] cache
[TRACE] trace

Thank you very much.

Never mind. The issue is that by default HAProxy logs the request URI it receives from the client and not the request URI after set-path that is why the logs will always show the original req.uri. The above configuration works as intended. Thanks

1 Like