@baptiste64, @baptiste64 thanks for your feedback, and apologies for double posting; will refrain from it in the future.
Having enabled proxy protocol on RabbitMQ backend, client application A is not able to connect to RabbitMQ (application B), and I see the below errors in RabbitMQ log -
2021-03-29 08:40:31.705 [error] <0.774.0> error when receiving proxy header: ‘The PROXY protocol header signature was not recognized. (PP 2.1, PP 2.2)’
2021-03-29 08:40:31.714 [error] <0.777.0> error when receiving proxy header: ‘The PROXY protocol header signature was not recognized. (PP 2.1, PP 2.2)’
2021-03-29 08:40:32.056 [error] <0.781.0> error when receiving proxy header: TCP socket was closed prematurely
2021-03-29 08:40:32.644 [error] <0.785.0> error when receiving proxy header: TCP socket was closed prematurely
Having run a tcpdump for HAProxy frontend port (9000) on application B i.e. RabbitMQ node, I see the following -
09:00:55.962827 “src iP”.35410 > “dest IP”.serverviewdbms: Flags [P.], seq 1:52, ack 1, win 211, options [nop,nop,TS val 2750902025 ecr 235343728], length 5
1
E…g…@.@.H.
.a3
.e…R#…z.D…2…
…o …pPROXY TCP4 “src IP” “dest IP” 35410 9000
09:00:55.962846 IP “src IP”.35410 > “dest IP”.serverviewdbms: Flags [P.], seq 52:187, ack 1, win 211, options [nop,nop,TS val 2750902025 ecr 235343728], length
135
E…@.@.H]
.a3
09:01:25.971836 IP “src IP”.35462 > “dest IP”>.serverviewdbms: Flags [P.], seq 1:52, ack 1, win 211, options [nop,nop,TS val 2750932034 ecr 235373737], length 5
1
E…gs.@.@…Z
.a3
.e…#.Oy…O…z…
…B…PROXY TCP4 “src IP” “dest IP” 35462 9000
09:01:25.971862 IP “src IP”.35462 > “dest IP”.serverviewdbms: Flags [P.], seq 52:219, ack 1, win 211, options [nop,nop,TS val 2750932034 ecr 235373737], length
167
E…s.@.@…
.a3
09:01:27.384586 IP “src IP”.35468 > “dest IP”.serverviewdbms: Flags [P.], seq 1:44, ack 1, win 211, options [nop,nop,TS val 2750933447 ecr 235375150], length 4
3
E…W9@.@…&
.a3
.e…#.…Wo…
…PROXY TCP4 127.0.0.1 127.0.0.1 58592 9000
Stopped HAProxy service on RabbitMQ node (application B), ran tcpdump command “tcpdump -n port 9000 -A | tee ascii-traffic-accept-proxy.log”, and started HAProxy service on RabbitMQ node. This resulted in the AMQP connection request initiated by client application A to be captured as part of the tcpdump, based on the understanding that the proxy protocol header will get added as part of the initial connection request only as AMQP connections are long-lived.
Looks like the proxy protocol header is getting added to the connection stream with the correct source and destination IP addresses, but at the end rather than at the start. Will this cause issues, and result in the behaviour mentioned above? Also, I see a proxy header with source address set to 127.0.0.1 IP address; not sure why?
The above test was run by modifying the HAProxy backend configuration on client application A to communicate with a single RabbitMQ node (application B) instead of using the SRV record, for simplicity of running the tests.
Not sure whether I also need to add send-proxy directive to HAProxy backend server line on RabbitMQ node (application B)? Having tested it with and without accept-proxy directive specified in HAProxy frontend, following are the results -
with accept-proxy
2021-03-29 09:04:34.414 [info] <0.766.0> Connection <0.766.0> (127.0.0.1:58736 → 127.0.0.1:5672) has a client-provided name: rabbitConnectionFactory#5b4da05e:7560
2021-03-29 09:04:34.416 [info] <0.766.0> connection <0.766.0> (127.0.0.1:58736 → 127.0.0.1:5672 - rabbitConnectionFactory#5b4da05e:7560): user ‘user’ authenticated and granted access to vhost ‘/’
2021-03-29 09:04:34.479 [error] <0.790.0> error when receiving proxy header: TCP socket was closed prematurely
2021-03-29 09:04:34.550 [error] <0.793.0> error when receiving proxy header: TCP socket was closed prematurely
client application A was able to connect to RabbitMQ, but the source client IP address was still not getting relayed. Also there were constant errors logged to RabbitMQ log file as seen in the above extract.
without accept-proxy
2021-03-29 09:06:54.025 [info] <0.2320.0> Connection <0.2320.0> (“src IP”:35692 → 127.0.0.1:5672) has a client-provided name: rabbitConnectionFactory#5b4da05e:7561
2021-03-29 09:06:54.028 [info] <0.2320.0> connection <0.2320.0> (“src IP”:35692 → 127.0.0.1:5672 - rabbitConnectionFactory#5b4da05e:7561): user ‘user’ authenticated and granted access to vhost ‘/’
2021-03-29 09:06:54.105 [error] <0.2347.0> error when receiving proxy header: TCP socket was closed prematurely
2021-03-29 09:06:54.245 [error] <0.2350.0> error when receiving proxy header: TCP socket was closed prematurely
client application A was able to connect to RabbitMQ, and the source client IP address was getting relayed. But there were constant errors logged to RabbitMQ log file as seen in the above extract.
Below is the output of haproxy -vv -
HA-Proxy version 2.0.14 2020/04/02 - https://haproxy.org/
Build options :
TARGET = linux-glibc
CPU = generic
CC = gcc
CFLAGS = -O2 -g -fno-strict-aliasing -Wdeclaration-after-statement -fwrapv -Wno-unused-label -Wno-sign-compare -Wno-unused-parameter -Wno-old-style-declaration -Wno-ignored-qualifiers -Wno-clobbered -Wno-missing-field-initializers -Wtype-limits
OPTIONS = USE_PCRE=1 USE_OPENSSL=1 USE_ZLIB=1 USE_SYSTEMD=1
Feature list : +EPOLL -KQUEUE -MY_EPOLL -MY_SPLICE +NETFILTER +PCRE -PCRE_JIT -PCRE2 -PCRE2_JIT +POLL -PRIVATE_CACHE +THREAD -PTHREAD_PSHARED -REGPARM -STATIC_PCRE -STATIC_PCRE2 +TPROXY +LINUX_TPROXY +LINUX_SPLICE +LIBCRYPT +CRYPT_H -VSYSCALL +GETADDRINFO +OPENSSL -LUA +FUTEX +ACCEPT4 -MY_ACCEPT4 +ZLIB -SLZ +CPU_AFFINITY +TFO +NS +DL +RT -DEVICEATLAS -51DEGREES -WURFL +SYSTEMD -OBSOLETE_LINKER +PRCTL +THREAD_DUMP -EVPORTS
Default settings :
bufsize = 16384, maxrewrite = 1024, maxpollevents = 200
Built with multi-threading support (MAX_THREADS=64, default=2).
Built with OpenSSL version : OpenSSL 1.0.2k-fips 26 Jan 2017
Running on OpenSSL version : OpenSSL 1.0.2k-fips 26 Jan 2017
OpenSSL library supports TLS extensions : yes
OpenSSL library supports SNI : yes
OpenSSL library supports : SSLv3 TLSv1.0 TLSv1.1 TLSv1.2
Built with network namespace support.
Built with transparent proxy support using: IP_TRANSPARENT IPV6_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 PCRE version : 8.32 2012-11-30
Running on PCRE version : 8.32 2012-11-30
PCRE library supports JIT : no (USE_PCRE_JIT not set)
Encrypted password support via crypt(3): yes
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 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