-
Notifications
You must be signed in to change notification settings - Fork 3
/
haproxy.cfg
69 lines (54 loc) · 2.2 KB
/
haproxy.cfg
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Copyright (C) 2020 WoltLab GmbH
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: LGPL-3.0-or-later
global
log stdout format short daemon
defaults
timeout connect 1s
timeout server 5s
timeout client 5s
frontend http
mode http
log global
log-format "[%tr] %ST %B %CC %CS %tsc %hr %hs %{+Q}r"
declare capture response len 4 # [+-]PHP
capture response header customer len 25
bind :::8080 v4v6
default_backend bk_customer
backend bk_customer
mode http
acl is_dynamic res.hdr(x-woltlab-cloud-dynamic) -m found
# Indicate whether this request was dynamic within the access log
http-response capture str(+PHP) id 0 if is_dynamic
http-response capture str(-PHP) id 0 unless is_dynamic
# Track the request in 'quota' stick table for the key "res.hdr(customer)".
http-response track-sc0 res.hdr(customer) table tracker/quota if is_dynamic
# And increase the counter.
http-response sc-inc-gpc0(0) if is_dynamic
server nginx 127.0.0.1:8081
# The "nginx" proxy pretends to be the nginx backend for simplicity. The returned header
# depends on whether the path ends in ".php", or not.
listen nginx
mode http
bind :::8081
http-request return status 200 content-type text/plain string "Dynamic" hdr customer "%[req.hdr(host)]" hdr x-woltlab-cloud-dynamic yes if { path_end .php }
http-request return status 200 content-type text/plain string "Static" hdr customer "%[req.hdr(host)]" unless { path_end .php }
peers tracker
log stdout format short daemon
table quota type string len 100 size 10000 store gpc0
bind :::20000 v4v6
server haproxy.example.com
server tracker 127.0.0.1:20001