File: proxy-localhost

package info (click to toggle)
haproxy 2.2.9-2%2Bdeb11u6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 16,012 kB
  • sloc: ansic: 166,229; javascript: 2,442; sh: 1,782; xml: 1,754; makefile: 1,068; python: 1,048; perl: 168
file content (49 lines) | stat: -rw-r--r-- 1,088 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/sh

set -eux

cat > /etc/haproxy/haproxy.cfg <<EOF
global
        chroot /var/lib/haproxy
        user haproxy
        group haproxy
        daemon
        maxconn 4096

defaults
        log global
        option dontlognull
        option redispatch
        retries 3
        timeout client 50s
        timeout connect 10s
        timeout http-request 5s
        timeout server 50s
        maxconn 4096

frontend test-front
    bind *:8080
    mode http
    default_backend test-back

backend test-back
    mode http
    stick store-request src
    stick-table type ip size 256k expire 30m
    server test-1 localhost:80
EOF

service haproxy restart
sleep 2  # Apache 2 could be still starting... See #976997.

# index.html is shipped with apache2
# Download it via haproxy and compare
if wget -t1 http://localhost:8080 -O- | cmp /var/www/html/index.html -; then
    echo "OK: index.html downloaded via haproxy matches the source file."
else
    echo "FAIL: downloaded index.html via haproxy is different from the"
    echo "      file delivered by apache."
    exit 1
fi

exit 0