Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 1 | varnishtest "Test the http-reuse with special connection parameters" |
Amaury Denoyelle | 8abbd2d | 2021-02-12 14:14:37 +0100 | [diff] [blame] | 2 | #REQUIRE_VERSION=2.4 |
| 3 | #REQUIRE_OPTIONS=OPENSSL |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | haproxy h1 -conf { |
| 8 | defaults |
| 9 | mode http |
| 10 | |
| 11 | # sni |
| 12 | listen sender-sni |
| 13 | bind "fd@${feS_sni}" |
Ilya Shipitsin | 19d1471 | 2021-03-19 22:31:14 +0500 | [diff] [blame] | 14 | server srv2 ${h1_feR_ssl_addr}:${h1_feR_ssl_port} ssl sni "req.hdr(x-sni)" verify none pool-low-conn 2 |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 15 | |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 16 | # 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 Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 24 | # 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 Denoyelle | ffcd290 | 2021-02-16 17:08:32 +0100 | [diff] [blame] | 29 | server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy pool-low-conn 2 |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 30 | |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 31 | listen receiver |
| 32 | bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 33 | bind "fd@${feR_proxy}" accept-proxy |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 34 | http-request return status 200 |
| 35 | http-after-response set-header http_first_request %[http_first_req] |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 36 | |
| 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 46 | } -start |
| 47 | |
| 48 | # http-reuse with sni parameters |
| 49 | client c_sni -connect ${h1_feS_sni_sock} { |
| 50 | # first request |
| 51 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 52 | -hdr "x-sni: www.custom.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 53 | rxresp |
| 54 | expect resp.http.http_first_request == "1" |
| 55 | |
| 56 | # second request with same sni, connection must be reused |
| 57 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 58 | -hdr "x-sni: www.custom.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 59 | 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 Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 64 | -hdr "x-sni: www.custom2.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 65 | rxresp |
| 66 | expect resp.http.http_first_request == "1" |
| 67 | |
| 68 | # fourth request, reuse sni2 |
| 69 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 70 | -hdr "x-sni: www.custom2.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 71 | rxresp |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 72 | expect resp.http.http_first_request == "0" |
| 73 | } -run |
| 74 | |
| 75 | # http-reuse with destination address |
| 76 | client 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 110 | expect resp.http.http_first_request == "0" |
| 111 | } -run |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 112 | |
| 113 | ## first request with proxy protocol |
| 114 | client 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 Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 126 | ## 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 |
| 129 | client 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 Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 137 | client 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 Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 144 | ## fourth request with different proxy protocol entry, no reuse |
| 145 | client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:60000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" { |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 146 | txreq |
| 147 | rxresp |
| 148 | expect resp.status == 200 |
| 149 | expect resp.http.http_first_request == "1" |
| 150 | } -run |
| 151 | |
Amaury Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 152 | ## fifth request, reuse proxy protocol |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 153 | client 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 Denoyelle | ffcd290 | 2021-02-16 17:08:32 +0100 | [diff] [blame] | 159 | txreq |
| 160 | rxresp |
| 161 | expect resp.status == 200 |
| 162 | expect resp.http.http_first_request == "0" |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 163 | } -run |