2021-01-22 15:35:22 +00:00
|
|
|
varnishtest "Test the http-reuse with special connection parameters"
|
2021-02-12 13:14:37 +00:00
|
|
|
#REQUIRE_VERSION=2.4
|
|
|
|
#REQUIRE_OPTIONS=OPENSSL
|
2021-01-22 15:35:22 +00:00
|
|
|
|
|
|
|
feature ignore_unknown_macro
|
|
|
|
|
|
|
|
haproxy h1 -conf {
|
|
|
|
defaults
|
|
|
|
mode http
|
|
|
|
|
|
|
|
# sni
|
|
|
|
listen sender-sni
|
|
|
|
bind "fd@${feS_sni}"
|
2021-03-19 17:31:14 +00:00
|
|
|
server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2
|
2021-01-22 15:35:22 +00:00
|
|
|
|
2021-01-11 16:21:49 +00:00
|
|
|
# set-dst
|
|
|
|
# specify dst1_addr for server, which should be identical to dst2_addr
|
|
|
|
# port is specified by the client in header x-dst-port
|
|
|
|
listen sender-set-dst
|
|
|
|
bind "fd@${feS_dst}"
|
|
|
|
http-request set-dst-port hdr(x-dst-port)
|
|
|
|
server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
|
|
|
|
|
2021-01-22 15:36:55 +00:00
|
|
|
# proxy protocol
|
|
|
|
# must use reuse always as consecutive requests are from different client
|
|
|
|
listen sender-proxy
|
|
|
|
bind "fd@${feS_proxy}" accept-proxy
|
|
|
|
http-reuse always
|
2021-02-16 16:08:32 +00:00
|
|
|
server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy pool-low-conn 2
|
2021-01-22 15:36:55 +00:00
|
|
|
|
2021-01-22 15:35:22 +00:00
|
|
|
listen receiver
|
|
|
|
bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
|
2021-01-22 15:36:55 +00:00
|
|
|
bind "fd@${feR_proxy}" accept-proxy
|
2021-01-22 15:35:22 +00:00
|
|
|
http-request return status 200
|
|
|
|
http-after-response set-header http_first_request %[http_first_req]
|
2021-01-11 16:21:49 +00:00
|
|
|
|
|
|
|
listen receiver-dst1
|
|
|
|
bind "fd@${feR_dst1}"
|
|
|
|
http-request return status 200 hdr "x-dst" "dst1"
|
|
|
|
http-after-response set-header http_first_request %[http_first_req]
|
|
|
|
|
|
|
|
listen receiver-dst2
|
|
|
|
bind "fd@${feR_dst2}"
|
|
|
|
http-request return status 200 hdr "x-dst" "dst2"
|
|
|
|
http-after-response set-header http_first_request %[http_first_req]
|
2021-01-22 15:35:22 +00:00
|
|
|
} -start
|
|
|
|
|
|
|
|
# http-reuse with sni parameters
|
|
|
|
client c_sni -connect ${h1_feS_sni_sock} {
|
|
|
|
# first request
|
|
|
|
txreq \
|
2021-02-12 14:22:43 +00:00
|
|
|
-hdr "x-sni: www.custom.com"
|
2021-01-22 15:35:22 +00:00
|
|
|
rxresp
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
|
|
|
|
# second request with same sni, connection must be reused
|
|
|
|
txreq \
|
2021-02-12 14:22:43 +00:00
|
|
|
-hdr "x-sni: www.custom.com"
|
2021-01-22 15:35:22 +00:00
|
|
|
rxresp
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
|
|
|
|
# third request with a different sni, a new connection must be used
|
|
|
|
txreq \
|
2021-02-12 14:22:43 +00:00
|
|
|
-hdr "x-sni: www.custom2.com"
|
2021-01-22 15:35:22 +00:00
|
|
|
rxresp
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
|
|
|
|
# fourth request, reuse sni2
|
|
|
|
txreq \
|
2021-02-12 14:22:43 +00:00
|
|
|
-hdr "x-sni: www.custom2.com"
|
2021-01-22 15:35:22 +00:00
|
|
|
rxresp
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
} -run
|
2021-01-11 16:21:49 +00:00
|
|
|
|
|
|
|
# http-reuse with destination address
|
|
|
|
client c_dst1 -connect ${h1_feS_dst_sock} {
|
|
|
|
txreq \
|
|
|
|
-hdr "x-dst-port: ${h1_feR_dst1_port}"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.x-dst == "dst1"
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
|
|
|
|
txreq \
|
|
|
|
-hdr "x-dst-port: ${h1_feR_dst1_port}"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.x-dst == "dst1"
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
|
|
|
|
txreq \
|
|
|
|
-hdr "x-dst-port: ${h1_feR_dst2_port}"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.x-dst == "dst2"
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
|
|
|
|
txreq \
|
|
|
|
-hdr "x-dst-port: ${h1_feR_dst1_port}"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.x-dst == "dst1"
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
|
|
|
|
txreq \
|
|
|
|
-hdr "x-dst-port: ${h1_feR_dst2_port}"
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.x-dst == "dst2"
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
} -run
|
2021-01-22 15:36:55 +00:00
|
|
|
|
|
|
|
## first request with proxy protocol
|
|
|
|
client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
} -run
|
|
|
|
|
2021-02-18 15:03:37 +00:00
|
|
|
## second request with different proxy protocol
|
|
|
|
# this have the nice effect to fill the server pool to 2 connection
|
|
|
|
# (pool-low-conn value) to allow takeover on multi thread run
|
|
|
|
client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
} -run
|
|
|
|
|
|
|
|
## third request, reuse same proxy protocol entry
|
2021-01-22 15:36:55 +00:00
|
|
|
client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
} -run
|
|
|
|
|
2021-02-18 15:03:37 +00:00
|
|
|
## fourth request with different proxy protocol entry, no reuse
|
|
|
|
client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:60000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
|
2021-01-22 15:36:55 +00:00
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "1"
|
|
|
|
} -run
|
|
|
|
|
2021-02-18 15:03:37 +00:00
|
|
|
## fifth request, reuse proxy protocol
|
2021-01-22 15:36:55 +00:00
|
|
|
client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
|
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "0"
|
|
|
|
|
2021-02-16 16:08:32 +00:00
|
|
|
txreq
|
|
|
|
rxresp
|
|
|
|
expect resp.status == 200
|
|
|
|
expect resp.http.http_first_request == "0"
|
2021-01-22 15:36:55 +00:00
|
|
|
} -run
|