mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-22 20:32:12 +00:00
cf6e0c8a83
This patch adds the `unique-id` option to `proxy-v2-options`. If this option is set a unique ID will be generated based on the `unique-id-format` while sending the proxy protocol v2 header and stored as the unique id for the first stream of the connection. This feature is meant to be used in `tcp` mode. It works on HTTP mode, but might result in inconsistent unique IDs for the first request on a keep-alive connection, because the unique ID for the first stream is generated earlier than the others. Now that we can send unique IDs in `tcp` mode the `%ID` log variable is made available in TCP mode.
43 lines
1.2 KiB
Plaintext
43 lines
1.2 KiB
Plaintext
varnishtest "Check that the unique ID TLV is properly sent"
|
|
|
|
#REQUIRE_VERSION=2.2
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
haproxy h1 -conf {
|
|
defaults
|
|
mode http
|
|
log global
|
|
unique-id-format %{+X}o\ TEST-%[req.hdr(in)]
|
|
|
|
listen sender
|
|
bind "fd@${feS}"
|
|
|
|
unique-id-header unique_id
|
|
|
|
server example ${h1_feR_addr}:${h1_feR_port} send-proxy-v2 proxy-v2-options unique-id
|
|
|
|
listen receiver
|
|
bind "fd@${feR}" accept-proxy
|
|
|
|
http-request set-var(txn.http_unique_id) req.hdr(unique_id)
|
|
http-request set-var(txn.proxy_unique_id) fc_pp_unique_id
|
|
http-after-response set-header http_unique_id %[var(txn.http_unique_id)]
|
|
http-after-response set-header proxy_unique_id %[var(txn.proxy_unique_id)]
|
|
http-request return status 200
|
|
} -start
|
|
|
|
# Validate that a correct header passes
|
|
client c1 -connect ${h1_feS_sock} {
|
|
txreq -url "/" \
|
|
-hdr "in: foo"
|
|
rxresp
|
|
expect resp.http.http_unique_id == "TEST-foo"
|
|
expect resp.http.proxy_unique_id == "TEST-foo"
|
|
txreq -url "/" \
|
|
-hdr "in: bar"
|
|
rxresp
|
|
expect resp.http.http_unique_id == "TEST-bar"
|
|
expect resp.http.proxy_unique_id == "TEST-foo"
|
|
} -run
|