blob: 58118d27dc0f9efcdb908c39fbfcb8dc03db81af [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}"
14 server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2
15
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
29 server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy
30
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
126## second request with same proxy protocol entry
127client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
128 txreq
129 rxresp
130 expect resp.status == 200
131 expect resp.http.http_first_request == "0"
132} -run
133
134## third request with different proxy protocol entry, no reuse
135client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
136 txreq
137 rxresp
138 expect resp.status == 200
139 expect resp.http.http_first_request == "1"
140} -run
141
142## fourth request, reuse proxy protocol
143client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" {
144 txreq
145 rxresp
146 expect resp.status == 200
147 expect resp.http.http_first_request == "0"
148
Amaury Denoyelle49aa5e92021-02-12 14:16:30 +0100149 # TODO this test does not pass on the CI
150 #txreq
151 #rxresp
152 #expect resp.status == 200
153 #expect resp.http.http_first_request == "0"
Amaury Denoyelle7ef06c82021-01-22 16:36:55 +0100154} -run