Christopher Faulet | e41b497 | 2021-10-13 18:06:55 +0200 | [diff] [blame] | 1 | varnishtest "Misuses of defaults section defining TCP/HTTP rules" |
| 2 | |
Tim Duesterhus | 41922af | 2021-11-04 21:12:14 +0100 | [diff] [blame] | 3 | feature cmd "$HAPROXY_PROGRAM -cc 'version_atleast(2.5-dev0)'" |
Christopher Faulet | e41b497 | 2021-10-13 18:06:55 +0200 | [diff] [blame] | 4 | feature ignore_unknown_macro |
| 5 | |
| 6 | # |
| 7 | # anonymous defaults section cannot define TCP/HTTP rules |
| 8 | # |
| 9 | haproxy h1 -conf-BAD {} { |
| 10 | defaults |
| 11 | http-request set-header X-Hdr 1 |
| 12 | } |
| 13 | |
| 14 | haproxy h2 -conf-BAD {} { |
| 15 | defaults |
| 16 | http-response set-header X-Hdr 1 |
| 17 | } |
| 18 | |
| 19 | haproxy h3 -conf-BAD {} { |
| 20 | defaults |
| 21 | http-after-request set-header X-Hdr 1 |
| 22 | } |
| 23 | |
| 24 | haproxy h4 -conf-BAD {} { |
| 25 | defaults |
| 26 | tcp-request connection accept |
| 27 | } |
| 28 | |
| 29 | haproxy h5 -conf-BAD {} { |
| 30 | defaults |
| 31 | tcp-request session accept |
| 32 | } |
| 33 | |
| 34 | haproxy h6 -conf-BAD {} { |
| 35 | defaults |
| 36 | tcp-request inspect-delay 5s |
| 37 | tcp-request content accept |
| 38 | } |
| 39 | |
| 40 | haproxy h7 -conf-BAD {} { |
| 41 | defaults |
| 42 | tcp-response inspect-delay 5s |
| 43 | tcp-response content accept |
| 44 | } |
| 45 | |
| 46 | # |
| 47 | # defaults section defining TCP/HTTP rules cannot be used to init another |
| 48 | # defaults section |
| 49 | # |
| 50 | haproxy h8 -conf-BAD {} { |
| 51 | defaults invalid |
| 52 | tcp-response inspect-delay 5s |
| 53 | tcp-response content accept |
| 54 | |
| 55 | defaults from invalid |
| 56 | mode tcp |
| 57 | } |
| 58 | |
| 59 | # |
| 60 | # defaults section defining TCP/HTTP rules cannot be used to init a listen |
| 61 | # section |
| 62 | # |
| 63 | haproxy h9 -conf-BAD {} { |
| 64 | defaults invalid |
| 65 | tcp-request inspect-delay 5s |
| 66 | tcp-request content accept |
| 67 | |
| 68 | listen li from invalid |
| 69 | mode tcp |
| 70 | bind "fd@${lih9}" |
| 71 | server www 127.0.0.1:80 |
| 72 | } |
| 73 | |
| 74 | # |
| 75 | # defaults section defining TCP/HTTP rules cannot be used to init frontend and |
| 76 | # backend sections at the same time |
| 77 | # |
| 78 | # |
| 79 | haproxy h10 -conf-BAD {} { |
| 80 | defaults invalid |
| 81 | tcp-request inspect-delay 5s |
| 82 | tcp-request content accept |
| 83 | |
| 84 | frontend fe from invalid |
| 85 | mode tcp |
| 86 | bind "fd@${feh10}" |
| 87 | default_backend be1 |
| 88 | |
| 89 | backend be from invalid |
| 90 | mode tcp |
| 91 | server www 127.0.0.1:80 |
| 92 | } |
| 93 | |
| 94 | # |
| 95 | # defaults section defining 'tcp-request connection' or 'tcp-request session' |
| 96 | # rules cannot be used to init backend sections |
| 97 | # |
| 98 | haproxy h11 -conf-BAD {} { |
| 99 | defaults invalid |
| 100 | tcp-request connection accept |
| 101 | |
| 102 | backend be from invalid |
| 103 | mode tcp |
| 104 | server www 127.0.0.1:80 |
| 105 | } |
| 106 | |
| 107 | haproxy h12 -conf-BAD {} { |
| 108 | defaults invalid |
| 109 | tcp-request session accept |
| 110 | |
| 111 | backend be from invalid |
| 112 | mode tcp |
| 113 | server www 127.0.0.1:80 |
| 114 | } |
| 115 | |
| 116 | # |
| 117 | # defaults section defining 'tcp-response content' rules cannot be used to init |
| 118 | # a frontend section |
| 119 | # |
| 120 | haproxy h13 -conf-BAD {} { |
| 121 | defaults invalid |
| 122 | tcp-response inspect-delay 5s |
| 123 | tcp-response content accept |
| 124 | |
| 125 | frontend fe from invalid |
| 126 | mode tcp |
| 127 | bind "fd@${feh10}" |
| 128 | } |
| 129 | |
| 130 | haproxy h14 -conf-OK { |
| 131 | defaults tcp |
| 132 | tcp-response inspect-delay 5s |
| 133 | tcp-response content accept |
| 134 | |
| 135 | backend be from tcp |
| 136 | mode tcp |
| 137 | server www 127.0.0.1:80 |
| 138 | } |
| 139 | |
| 140 | # |
| 141 | # Check arguments resolutions in rules. FE/BE arguments must be resolved, but |
| 142 | # SRV/TAB arguments without an explicit proxy name are not allowed. |
| 143 | # |
| 144 | |
| 145 | haproxy h15 -conf-BAD {} { |
| 146 | defaults invalid |
| 147 | mode http |
| 148 | http-request set-header x-test "%[srv_conn(www)]" |
| 149 | |
| 150 | backend be from invalid |
| 151 | server www 127.0.0.1:80 |
| 152 | } |
| 153 | |
| 154 | haproxy h16 -conf-BAD {} { |
| 155 | defaults invalid |
| 156 | mode http |
| 157 | http-request track-sc0 src |
| 158 | http-request deny deny_status 429 if { sc_http_req_rate(0) gt 20 } |
| 159 | |
| 160 | backend be |
| 161 | stick-table type ip size 100k expire 30s store http_req_rate(10s) |
| 162 | server www 127.0.0.1:80 |
| 163 | } |
| 164 | |
| 165 | haproxy h17 -conf-OK { |
| 166 | defaults common |
| 167 | mode http |
| 168 | |
| 169 | defaults def_front from common |
| 170 | http-request set-header x-test1 "%[fe_conn]" |
| 171 | |
| 172 | defaults def_back from common |
| 173 | http-request track-sc0 src table be |
| 174 | http-request deny deny_status 429 if { sc_http_req_rate(0,be) gt 20 } |
| 175 | http-request set-header x-test2 "%[be_conn]" |
| 176 | http-request set-header x-test3 "%[srv_conn(be/www)]" |
| 177 | |
| 178 | frontend fe from def_front |
| 179 | bind "fd@${feh15}" |
| 180 | default_backend be |
| 181 | |
| 182 | backend be from def_back |
| 183 | stick-table type ip size 100k expire 30s store http_req_rate(10s) |
| 184 | server www 127.0.0.1:80 |
| 185 | } |