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