Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 1 | varnishtest "Test the http-reuse with special connection parameters" |
| 2 | |
| 3 | feature ignore_unknown_macro |
| 4 | |
| 5 | haproxy 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 Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 14 | # 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 Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 22 | # proxy protocol |
| 23 | # must use reuse always as consecutive requests are from different client |
| 24 | listen sender-proxy |
| 25 | bind "fd@${feS_proxy}" accept-proxy |
| 26 | http-reuse always |
| 27 | server srv2 ${h1_feR_proxy_addr}:${h1_feR_proxy_port} send-proxy |
| 28 | |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 29 | listen receiver |
| 30 | bind "fd@${feR_ssl}" ssl crt ${testdir}/common.pem |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 31 | bind "fd@${feR_proxy}" accept-proxy |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 32 | http-request return status 200 |
| 33 | http-after-response set-header http_first_request %[http_first_req] |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 34 | |
| 35 | listen receiver-dst1 |
| 36 | bind "fd@${feR_dst1}" |
| 37 | http-request return status 200 hdr "x-dst" "dst1" |
| 38 | http-after-response set-header http_first_request %[http_first_req] |
| 39 | |
| 40 | listen receiver-dst2 |
| 41 | bind "fd@${feR_dst2}" |
| 42 | http-request return status 200 hdr "x-dst" "dst2" |
| 43 | http-after-response set-header http_first_request %[http_first_req] |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 44 | } -start |
| 45 | |
| 46 | # http-reuse with sni parameters |
| 47 | client c_sni -connect ${h1_feS_sni_sock} { |
| 48 | # first request |
| 49 | txreq \ |
| 50 | -hdr "x-sni: custom_sni" |
| 51 | rxresp |
| 52 | expect resp.http.http_first_request == "1" |
| 53 | |
| 54 | # second request with same sni, connection must be reused |
| 55 | txreq \ |
| 56 | -hdr "x-sni: custom_sni" |
| 57 | rxresp |
| 58 | expect resp.http.http_first_request == "0" |
| 59 | |
| 60 | # third request with a different sni, a new connection must be used |
| 61 | txreq \ |
| 62 | -hdr "x-sni: custom_sni_2" |
| 63 | rxresp |
| 64 | expect resp.http.http_first_request == "1" |
| 65 | |
| 66 | # fourth request, reuse sni2 |
| 67 | txreq \ |
| 68 | -hdr "x-sni: custom_sni_2" |
| 69 | rxresp |
Amaury Denoyelle | f679d9b | 2021-01-11 17:21:49 +0100 | [diff] [blame] | 70 | expect resp.http.http_first_request == "0" |
| 71 | } -run |
| 72 | |
| 73 | # http-reuse with destination address |
| 74 | client c_dst1 -connect ${h1_feS_dst_sock} { |
| 75 | txreq \ |
| 76 | -hdr "x-dst-port: ${h1_feR_dst1_port}" |
| 77 | rxresp |
| 78 | expect resp.status == 200 |
| 79 | expect resp.http.x-dst == "dst1" |
| 80 | expect resp.http.http_first_request == "1" |
| 81 | |
| 82 | txreq \ |
| 83 | -hdr "x-dst-port: ${h1_feR_dst1_port}" |
| 84 | rxresp |
| 85 | expect resp.status == 200 |
| 86 | expect resp.http.x-dst == "dst1" |
| 87 | expect resp.http.http_first_request == "0" |
| 88 | |
| 89 | txreq \ |
| 90 | -hdr "x-dst-port: ${h1_feR_dst2_port}" |
| 91 | rxresp |
| 92 | expect resp.status == 200 |
| 93 | expect resp.http.x-dst == "dst2" |
| 94 | expect resp.http.http_first_request == "1" |
| 95 | |
| 96 | txreq \ |
| 97 | -hdr "x-dst-port: ${h1_feR_dst1_port}" |
| 98 | rxresp |
| 99 | expect resp.status == 200 |
| 100 | expect resp.http.x-dst == "dst1" |
| 101 | expect resp.http.http_first_request == "0" |
| 102 | |
| 103 | txreq \ |
| 104 | -hdr "x-dst-port: ${h1_feR_dst2_port}" |
| 105 | rxresp |
| 106 | expect resp.status == 200 |
| 107 | expect resp.http.x-dst == "dst2" |
Amaury Denoyelle | e676239 | 2021-01-22 16:35:22 +0100 | [diff] [blame] | 108 | expect resp.http.http_first_request == "0" |
| 109 | } -run |
Amaury Denoyelle | 7ef06c8 | 2021-01-22 16:36:55 +0100 | [diff] [blame] | 110 | |
| 111 | ## first request with proxy protocol |
| 112 | client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" { |
| 113 | txreq |
| 114 | rxresp |
| 115 | expect resp.status == 200 |
| 116 | expect resp.http.http_first_request == "1" |
| 117 | |
| 118 | txreq |
| 119 | rxresp |
| 120 | expect resp.status == 200 |
| 121 | expect resp.http.http_first_request == "0" |
| 122 | } -run |
| 123 | |
| 124 | ## second request with same proxy protocol entry |
| 125 | client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:40000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" { |
| 126 | txreq |
| 127 | rxresp |
| 128 | expect resp.status == 200 |
| 129 | expect resp.http.http_first_request == "0" |
| 130 | } -run |
| 131 | |
| 132 | ## third request with different proxy protocol entry, no reuse |
| 133 | client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" { |
| 134 | txreq |
| 135 | rxresp |
| 136 | expect resp.status == 200 |
| 137 | expect resp.http.http_first_request == "1" |
| 138 | } -run |
| 139 | |
| 140 | ## fourth request, reuse proxy protocol |
| 141 | client c_proxy -connect ${h1_feS_proxy_sock} -proxy1 "127.0.0.1:50000 ${h1_feS_proxy_addr}:${h1_feS_proxy_port}" { |
| 142 | txreq |
| 143 | rxresp |
| 144 | expect resp.status == 200 |
| 145 | expect resp.http.http_first_request == "0" |
| 146 | |
| 147 | txreq |
| 148 | rxresp |
| 149 | expect resp.status == 200 |
| 150 | expect resp.http.http_first_request == "0" |
| 151 | } -run |