-
Notifications
You must be signed in to change notification settings - Fork 40
/
haproxy.cfg
executable file
·120 lines (96 loc) · 4.86 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Global configuration for HAProxy
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#3
global
# Bind UNIX socket to get various stats
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#stats
stats socket /var/run/haproxy.sock mode 600 level admin
# Bind TCP port to get various stats
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#stats
stats socket [email protected]:9999 level admin
# Define the timeout on the stats
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#3.1-stats%20timeout
stats timeout 30s
# Configure the way the logging is done
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#log
log 127.0.0.1 local1 notice
# Configure defaults for all the proxies configuration (applied for all the next sections in the configuration)
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4
defaults
# Enable logging
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-log
log global
# The default mode for all the services
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-bind
mode http
# Enable the logging of HTTP requests
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-option%20httplog
option httplog
# Enable the logging of null connections
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-option%20dontlognull
option dontlognull
# Configure the timeout to connect to a server
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-timeout%20connect
timeout connect 5000
# Configure the timeout before cutting the connection of a client
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-timeout%20client
timeout client 50000
# Same kind of configuration for the servers side
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-timeout%20server
timeout server 50000
# Open the metrics HAProxy page on the port 1936 on any network interface on the host
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4
listen stats
bind *:1936
# Enable HAProxy to serve stats about himself and the nodes
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-stats%20enable
stats enable
# Define the URI to access the stats
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-stats%20uri
stats uri /
# Avoid leaking more info than necessary with hiding the version of HAProxy
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-stats%20hide-version
stats hide-version
# Define the frontend configuration. In fact, that's the part that configure how HAProxy will handle
# the requests from the outside world:
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4
frontend localnodes
# Bind the port 80 to listen incoming outside connections (from the outside world)
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-bind
bind *:80
# Define which protocol is enabled on the binded ports.
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-mode
mode http
# Use the backend configuration references by the backend name section in this configuration
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-default_backend
default_backend nodes
# Define the backend configuration. In fact, that's the part that configure what is not directly
# accessible from the outside of the network.
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4
backend nodes
# Define the protocol accepted
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-mode
mode http
# Define the way the backend nodes are checked to know if they are alive or down
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-option%20httpchk
option httpchk HEAD /
# Define the balancing policy
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#balance
balance roundrobin
# Automatically add the X-Forwarded-For header
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-option%20forwardfor
# https://en.wikipedia.org/wiki/X-Forwarded-For
option forwardfor
# With this config, we add the header X-Forwarded-Port
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-http-request
http-request set-header X-Forwarded-Port %[dst_port]
# Define the list of nodes to be in the balancing mechanism
# http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-server
# HANDLEBARS START
# TODO: [CFG] Remove all the servers
server s1 ${WEBAPP_1_IP}:3000 check
server s2 ${WEBAPP_2_IP}:3000 check
# HANDLEBARS STOP
# Other links you will need later for this lab
#
# About cookies: http://cbonte.github.io/haproxy-dconv/2.2/configuration.html#4-cookie
#