blob: bd0d3db7fb94a1023a156800dfe379f2920b5057 [file] [log] [blame]
Christopher Fauletf7177272020-10-02 13:41:55 +02001varnishtest "Health-checks: basic HTTP health-check though a socks4 proxy"
2#REQUIRE_VERSION=2.0
3#REGTEST_TYPE=slow
4feature ignore_unknown_macro
5
6# This scripts tests a simple HTTP health-checks though a socks4 proxy.
7
8server s1 {
9} -start
10
11server socks {
12 ## get socks4 request
13 recv 16
14
15 ## send socks4 response :
16 ## constant(1): 0x00
17 ## statut(1) : 0x5a (success)
18 ## padding(6) : ignored
19 sendhex "005A000000000000"
20
21 rxreq
22 expect req.method == OPTIONS
23 expect req.url == /
24 expect req.proto == HTTP/1.0
25 txresp
26} -start
27
28syslog S1 -level notice {
29 recv
30 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Proxy be1 started."
31 recv
32 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+code: 200.+check duration: [[:digit:]]+ms, status: 1/1 UP."
33} -start
34
35haproxy h1 -conf {
36 defaults
37 mode tcp
38 timeout client 1s
39 timeout server 1s
40 timeout connect 100ms
41
42 backend be1
43 log ${S1_addr}:${S1_port} daemon
44 option log-health-checks
45 option httpchk
46 server srv ${s1_addr}:${s1_port} socks4 ${h1_socks_addr}:${h1_socks_port} check-via-socks4 check inter 1s rise 1 fall 1
47
48 listen socks
49 bind "fd@${socks}"
50 tcp-request inspect-delay 500ms
51 ## Accept socks4 request on 16 bytes :
52 ## version(1) : 0x04
53 ## command(1) : 0x01
54 ## port(2) : ${s1_port}
55 ## addr(4) : ${s1_addr}
56 ## user-id : "HAProxy\0"
57 tcp-request content accept if { req.len eq 16 } { req.payload(0,1) -m bin "04" } { req.payload(1,1) -m bin "01" } { req.payload(2,2),hex,hex2i eq ${s1_port} } { req.payload(4,4),hex,hex2i -m ip ${s1_addr} } { req.payload(8,8) -m bin "484150726F787900" }
58 tcp-request content reject
59 server srv ${socks_addr}:${socks_port}
60
61} -start
62
63syslog S1 -wait