blob: 81d16f96371e98124a5ecb00170ebcb24c2ae324 [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
Amaury Denoyelled8ea1882021-02-19 15:37:40 +010012 # ssl-reuse is disabled because it seems to be the origin of a crash with
13 # libressl from 3.2.2 on the CI (cf github issue #1115)
Amaury Denoyellee6762392021-01-22 16:35:22 +010014 listen sender-sni
15 bind "fd@${feS_sni}"
Amaury Denoyelled8ea1882021-02-19 15:37:40 +010016 server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2 no-ssl-reuse
Amaury Denoyellee6762392021-01-22 16:35:22 +010017
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010018 # set-dst
19 # specify dst1_addr for server, which should be identical to dst2_addr
20 # port is specified by the client in header x-dst-port
21 listen sender-set-dst
22 bind "fd@${feS_dst}"
23 http-request set-dst-port hdr(x-dst-port)
24 server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
25
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010026 # proxy protocol
27 # must use reuse always as consecutive requests are from different client
28 listen sender-proxy
29 bind "fd@${feS_proxy}" accept-proxy
30 http-reuse always
Amaury Denoyelleffcd2902021-02-16 17:08:32 +010031 server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy pool-low-conn 2
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010032
Amaury Denoyellee6762392021-01-22 16:35:22 +010033 listen receiver
34 bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +010035 bind "fd@${feR_proxy}" accept-proxy
Amaury Denoyellee6762392021-01-22 16:35:22 +010036 http-request return status 200
37 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010038
39 listen receiver-dst1
40 bind "fd@${feR_dst1}"
41 http-request return status 200 hdr "x-dst" "dst1"
42 http-after-response set-header http_first_request %[http_first_req]
43
44 listen receiver-dst2
45 bind "fd@${feR_dst2}"
46 http-request return status 200 hdr "x-dst" "dst2"
47 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellee6762392021-01-22 16:35:22 +010048} -start
49
50# http-reuse with sni parameters
51client c_sni -connect ${h1_feS_sni_sock} {
52 # first request
53 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010054 -hdr "x-sni: www.custom.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010055 rxresp
56 expect resp.http.http_first_request == "1"
57
58 # second request with same sni, connection must be reused
59 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010060 -hdr "x-sni: www.custom.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010061 rxresp
62 expect resp.http.http_first_request == "0"
63
64 # third request with a different sni, a new connection must be used
65 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010066 -hdr "x-sni: www.custom2.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010067 rxresp
68 expect resp.http.http_first_request == "1"
69
70 # fourth request, reuse sni2
71 txreq \
Amaury Denoyelle7f583be2021-02-12 15:22:43 +010072 -hdr "x-sni: www.custom2.com"
Amaury Denoyellee6762392021-01-22 16:35:22 +010073 rxresp
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010074 expect resp.http.http_first_request == "0"
75} -run
76
77# http-reuse with destination address
78client c_dst1 -connect ${h1_feS_dst_sock} {
79 txreq \
80 -hdr "x-dst-port: ${h1_feR_dst1_port}"
81 rxresp
82 expect resp.status == 200
83 expect resp.http.x-dst == "dst1"
84 expect resp.http.http_first_request == "1"
85
86 txreq \
87 -hdr "x-dst-port: ${h1_feR_dst1_port}"
88 rxresp
89 expect resp.status == 200
90 expect resp.http.x-dst == "dst1"
91 expect resp.http.http_first_request == "0"
92
93 txreq \
94 -hdr "x-dst-port: ${h1_feR_dst2_port}"
95 rxresp
96 expect resp.status == 200
97 expect resp.http.x-dst == "dst2"
98 expect resp.http.http_first_request == "1"
99
100 txreq \
101 -hdr "x-dst-port: ${h1_feR_dst1_port}"
102 rxresp
103 expect resp.status == 200
104 expect resp.http.x-dst == "dst1"
105 expect resp.http.http_first_request == "0"
106
107 txreq \
108 -hdr "x-dst-port: ${h1_feR_dst2_port}"
109 rxresp
110 expect resp.status == 200
111 expect resp.http.x-dst == "dst2"
Amaury Denoyellee6762392021-01-22 16:35:22 +0100112 expect resp.http.http_first_request == "0"
113} -run
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100114
115## first request with proxy protocol
116client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
117 txreq
118 rxresp
119 expect resp.status == 200
120 expect resp.http.http_first_request == "1"
121
122 txreq
123 rxresp
124 expect resp.status == 200
125 expect resp.http.http_first_request == "0"
126} -run
127
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100128## second request with different proxy protocol
129# this have the nice effect to fill the server pool to 2 connection
130# (pool-low-conn value) to allow takeover on multi thread run
131client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
132 txreq
133 rxresp
134 expect resp.status == 200
135 expect resp.http.http_first_request == "1"
136} -run
137
138## third request, reuse same proxy protocol entry
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100139client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
140 txreq
141 rxresp
142 expect resp.status == 200
143 expect resp.http.http_first_request == "0"
144} -run
145
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100146## fourth request with different proxy protocol entry, no reuse
147client 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 +0100148 txreq
149 rxresp
150 expect resp.status == 200
151 expect resp.http.http_first_request == "1"
152} -run
153
Amaury Denoyelle4cce7082021-02-18 16:03:37 +0100154## fifth request, reuse proxy protocol
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100155client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
156 txreq
157 rxresp
158 expect resp.status == 200
159 expect resp.http.http_first_request == "0"
160
Amaury Denoyelleffcd2902021-02-16 17:08:32 +0100161 txreq
162 rxresp
163 expect resp.status == 200
164 expect resp.http.http_first_request == "0"
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100165} -run