blob: 991e86f7a8e411599d9a222ae831fa362a02ff7a [file] [log] [blame]
Amaury Denoyellee6762392021-01-22 16:35:22 +01001varnishtest "Test the http-reuse with special connection parameters"
Amaury Denoyelle8abbd2d2021-02-12 14:14:37 +01002#REQUIRE_VERSION=2.4
3#REQUIRE_OPTIONS=OPENSSL
Amaury Denoyellee6762392021-01-22 16:35:22 +01004
5feature ignore_unknown_macro
6
7haproxy h1 -conf {
8 defaults
9 mode http
10
11 # sni
12 listen sender-sni
13 bind "fd@${feS_sni}"
Ilya Shipitsin19d14712021-03-19 22:31:14 +050014 server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2
Amaury Denoyellee6762392021-01-22 16:35:22 +010015
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010016 # set-dst
17 # specify dst1_addr for server, which should be identical to dst2_addr
18 # port is specified by the client in header x-dst-port
19 listen sender-set-dst
20 bind "fd@${feS_dst}"
21 http-request set-dst-port hdr(x-dst-port)
22 server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
23
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010024 # proxy protocol
25 # must use reuse always as consecutive requests are from different client
26 listen sender-proxy
27 bind "fd@${feS_proxy}" accept-proxy
28 http-reuse always
Amaury Denoyelleffcd2902021-02-16 17:08:32 +010029 server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy pool-low-conn 2
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010030
Amaury Denoyellee6762392021-01-22 16:35:22 +010031 listen receiver
32 bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010033 bind "fd@${feR_proxy}" accept-proxy
Amaury Denoyellee6762392021-01-22 16:35:22 +010034 http-request return status 200
35 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010036
37 listen receiver-dst1
38 bind "fd@${feR_dst1}"
39 http-request return status 200 hdr "x-dst" "dst1"
40 http-after-response set-header http_first_request %[http_first_req]
41
42 listen receiver-dst2
43 bind "fd@${feR_dst2}"
44 http-request return status 200 hdr "x-dst" "dst2"
45 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellee6762392021-01-22 16:35:22 +010046} -start
47
48# http-reuse with sni parameters
49client c_sni -connect ${h1_feS_sni_sock} {
50 # first request
51 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010052 -hdr "x-sni: www.custom.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010053 rxresp
54 expect resp.http.http_first_request == "1"
55
56 # second request with same sni, connection must be reused
57 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010058 -hdr "x-sni: www.custom.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010059 rxresp
60 expect resp.http.http_first_request == "0"
61
62 # third request with a different sni, a new connection must be used
63 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010064 -hdr "x-sni: www.custom2.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010065 rxresp
66 expect resp.http.http_first_request == "1"
67
68 # fourth request, reuse sni2
69 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010070 -hdr "x-sni: www.custom2.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010071 rxresp
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010072 expect resp.http.http_first_request == "0"
73} -run
74
75# http-reuse with destination address
76client c_dst1 -connect ${h1_feS_dst_sock} {
77 txreq \
78 -hdr "x-dst-port: ${h1_feR_dst1_port}"
79 rxresp
80 expect resp.status == 200
81 expect resp.http.x-dst == "dst1"
82 expect resp.http.http_first_request == "1"
83
84 txreq \
85 -hdr "x-dst-port: ${h1_feR_dst1_port}"
86 rxresp
87 expect resp.status == 200
88 expect resp.http.x-dst == "dst1"
89 expect resp.http.http_first_request == "0"
90
91 txreq \
92 -hdr "x-dst-port: ${h1_feR_dst2_port}"
93 rxresp
94 expect resp.status == 200
95 expect resp.http.x-dst == "dst2"
96 expect resp.http.http_first_request == "1"
97
98 txreq \
99 -hdr "x-dst-port: ${h1_feR_dst1_port}"
100 rxresp
101 expect resp.status == 200
102 expect resp.http.x-dst == "dst1"
103 expect resp.http.http_first_request == "0"
104
105 txreq \
106 -hdr "x-dst-port: ${h1_feR_dst2_port}"
107 rxresp
108 expect resp.status == 200
109 expect resp.http.x-dst == "dst2"
Amaury Denoyellee6762392021-01-22 16:35:22 +0100110 expect resp.http.http_first_request == "0"
111} -run
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100112
113## first request with proxy protocol
114client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
115 txreq
116 rxresp
117 expect resp.status == 200
118 expect resp.http.http_first_request == "1"
119
120 txreq
121 rxresp
122 expect resp.status == 200
123 expect resp.http.http_first_request == "0"
124} -run
125
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100126## second request with different proxy protocol
127# this have the nice effect to fill the server pool to 2 connection
128# (pool-low-conn value) to allow takeover on multi thread run
129client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
130 txreq
131 rxresp
132 expect resp.status == 200
133 expect resp.http.http_first_request == "1"
134} -run
135
136## third request, reuse same proxy protocol entry
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100137client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
138 txreq
139 rxresp
140 expect resp.status == 200
141 expect resp.http.http_first_request == "0"
142} -run
143
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100144## fourth request with different proxy protocol entry, no reuse
145client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:60000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100146 txreq
147 rxresp
148 expect resp.status == 200
149 expect resp.http.http_first_request == "1"
150} -run
151
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100152## fifth request, reuse proxy protocol
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100153client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
154 txreq
155 rxresp
156 expect resp.status == 200
157 expect resp.http.http_first_request == "0"
158
Amaury Denoyelleffcd2902021-02-16 17:08:32 +0100159 txreq
160 rxresp
161 expect resp.status == 200
162 expect resp.http.http_first_request == "0"
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100163} -run