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 |
Amaury Denoyelle | d8ea188 | 2021-02-19 15:37:40 +0100 | [diff] [blame] | 12 | # 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 14 | listen sender-sni |
| 15 | bind "fd@${feS_sni}" |
Amaury Denoyelle | d8ea188 | 2021-02-19 15:37:40 +0100 | [diff] [blame] | 16 | 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 17 | |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 18 | # 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 Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 26 | # 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 Denoyelle | ffcd290 | 2021-02-16 17:08:32 +0100 | [diff] [blame] | 31 | 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] | 32 | |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 33 | listen receiver |
| 34 | bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 35 | bind "fd@${feR_proxy}" accept-proxy |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 36 | http-request return status 200 |
| 37 | http-after-response set-header http_first_request %[http_first_req] |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 38 | |
| 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 48 | } -start |
| 49 | |
| 50 | # http-reuse with sni parameters |
| 51 | client c_sni -connect ${h1_feS_sni_sock} { |
| 52 | # first request |
| 53 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 54 | -hdr "x-sni: www.custom.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 55 | rxresp |
| 56 | expect resp.http.http_first_request == "1" |
| 57 | |
| 58 | # second request with same sni, connection must be reused |
| 59 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 60 | -hdr "x-sni: www.custom.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 61 | 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 Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 66 | -hdr "x-sni: www.custom2.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 67 | rxresp |
| 68 | expect resp.http.http_first_request == "1" |
| 69 | |
| 70 | # fourth request, reuse sni2 |
| 71 | txreq \ |
Amaury Denoyelle | 7f583be | 2021-02-12 15:22:43 +0100 | [diff] [blame] | 72 | -hdr "x-sni: www.custom2.com" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 73 | rxresp |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 74 | expect resp.http.http_first_request == "0" |
| 75 | } -run |
| 76 | |
| 77 | # http-reuse with destination address |
| 78 | client 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 Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 112 | expect resp.http.http_first_request == "0" |
| 113 | } -run |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 114 | |
| 115 | ## first request with proxy protocol |
| 116 | client 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 Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 128 | ## 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 |
| 131 | client 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 Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 139 | client 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 Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 146 | ## fourth request with different proxy protocol entry, no reuse |
| 147 | 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] | 148 | txreq |
| 149 | rxresp |
| 150 | expect resp.status == 200 |
| 151 | expect resp.http.http_first_request == "1" |
| 152 | } -run |
| 153 | |
Amaury Denoyelle | 4cce708 | 2021-02-18 16:03:37 +0100 | [diff] [blame] | 154 | ## fifth request, reuse proxy protocol |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 155 | client 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 Denoyelle | ffcd290 | 2021-02-16 17:08:32 +0100 | [diff] [blame] | 161 | txreq |
| 162 | rxresp |
| 163 | expect resp.status == 200 |
| 164 | expect resp.http.http_first_request == "0" |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 165 | } -run |