blob: e0adefc8df8437765296831ac1c0788a3b60484e [file] [log] [blame]
Amaury Denoyellee6762392021-01-22 16:35:22 +01001varnishtest "Test the http-reuse with special connection parameters"
2
3feature ignore_unknown_macro
4
5haproxy h1 -conf {
6 defaults
7 mode http
8
9 # sni
10 listen sender-sni
11 bind "fd@${feS_sni}"
12 server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2
13
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010014 # set-dst
15 # specify dst1_addr for server, which should be identical to dst2_addr
16 # port is specified by the client in header x-dst-port
17 listen sender-set-dst
18 bind "fd@${feS_dst}"
19 http-request set-dst-port hdr(x-dst-port)
20 server srv2 ${h1_feR_dst1_addr}:0 pool-low-conn 2
21
Amaury Denoyellee6762392021-01-22 16:35:22 +010022 listen receiver
23 bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem
24 http-request return status 200
25 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010026
27 listen receiver-dst1
28 bind "fd@${feR_dst1}"
29 http-request return status 200 hdr "x-dst" "dst1"
30 http-after-response set-header http_first_request %[http_first_req]
31
32 listen receiver-dst2
33 bind "fd@${feR_dst2}"
34 http-request return status 200 hdr "x-dst" "dst2"
35 http-after-response set-header http_first_request %[http_first_req]
Amaury Denoyellee6762392021-01-22 16:35:22 +010036} -start
37
38# http-reuse with sni parameters
39client c_sni -connect ${h1_feS_sni_sock} {
40 # first request
41 txreq \
42 -hdr "x-sni: custom_sni"
43 rxresp
44 expect resp.http.http_first_request == "1"
45
46 # second request with same sni, connection must be reused
47 txreq \
48 -hdr "x-sni: custom_sni"
49 rxresp
50 expect resp.http.http_first_request == "0"
51
52 # third request with a different sni, a new connection must be used
53 txreq \
54 -hdr "x-sni: custom_sni_2"
55 rxresp
56 expect resp.http.http_first_request == "1"
57
58 # fourth request, reuse sni2
59 txreq \
60 -hdr "x-sni: custom_sni_2"
61 rxresp
Amaury Denoyellef679d9b2021-01-11 17:21:49 +010062 expect resp.http.http_first_request == "0"
63} -run
64
65# http-reuse with destination address
66client c_dst1 -connect ${h1_feS_dst_sock} {
67 txreq \
68 -hdr "x-dst-port: ${h1_feR_dst1_port}"
69 rxresp
70 expect resp.status == 200
71 expect resp.http.x-dst == "dst1"
72 expect resp.http.http_first_request == "1"
73
74 txreq \
75 -hdr "x-dst-port: ${h1_feR_dst1_port}"
76 rxresp
77 expect resp.status == 200
78 expect resp.http.x-dst == "dst1"
79 expect resp.http.http_first_request == "0"
80
81 txreq \
82 -hdr "x-dst-port: ${h1_feR_dst2_port}"
83 rxresp
84 expect resp.status == 200
85 expect resp.http.x-dst == "dst2"
86 expect resp.http.http_first_request == "1"
87
88 txreq \
89 -hdr "x-dst-port: ${h1_feR_dst1_port}"
90 rxresp
91 expect resp.status == 200
92 expect resp.http.x-dst == "dst1"
93 expect resp.http.http_first_request == "0"
94
95 txreq \
96 -hdr "x-dst-port: ${h1_feR_dst2_port}"
97 rxresp
98 expect resp.status == 200
99 expect resp.http.x-dst == "dst2"
Amaury Denoyellee6762392021-01-22 16:35:22 +0100100 expect resp.http.http_first_request == "0"
101} -run