blob: 995298dfc45f04c6897f51303764ceb9fbcda4fb [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
Christopher Fauletf7177272020-10-02 13:41:55 +020030 expect ~ "[^:\\[ ]\\[${h1_pid}\\]: Health check for server be1/srv succeeded, reason: Layer7 check passed.+code: 200.+check duration: [[:digit:]]+ms, status: 1/1 UP."
31} -start
32
33haproxy h1 -conf {
34 defaults
35 mode tcp
36 timeout client 1s
37 timeout server 1s
38 timeout connect 100ms
39
40 backend be1
41 log ${S1_addr}:${S1_port} daemon
42 option log-health-checks
43 option httpchk
44 server srv ${s1_addr}:${s1_port} socks4 ${h1_socks_addr}:${h1_socks_port} check-via-socks4 check inter 1s rise 1 fall 1
45
46 listen socks
47 bind "fd@${socks}"
48 tcp-request inspect-delay 500ms
49 ## Accept socks4 request on 16 bytes :
50 ## version(1) : 0x04
51 ## command(1) : 0x01
52 ## port(2) : ${s1_port}
53 ## addr(4) : ${s1_addr}
54 ## user-id : "HAProxy\0"
55 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" }
56 tcp-request content reject
57 server srv ${socks_addr}:${socks_port}
58
59} -start
60
61syslog S1 -wait