Class: RhaproxyGlobal
- Inherits:
-
Object
- Object
- RhaproxyGlobal
- Defined in:
- lib/rhaproxy/global.rb
Overview
Parameters in the “global” section are process-wide and often OS-specific. They are generally set once for all and do not need being changed once correct. Some of them have command-line equivalents.
Instance Attribute Summary collapse
-
#chroot ⇒ Object
chroot <jail dir> Changes current directory to <jail dir> and performs a chroot() there before dropping privileges.
-
#daemon ⇒ Object
daemon Makes the process fork into background.
-
#debug ⇒ Object
debug Enables debug mode which dumps to stdout all exchanges, and disables forking into background.
-
#description ⇒ Object
description <text> Add a text that describes the instance.
-
#gid ⇒ Object
gid <number> Changes the process’ group ID to <number>.
-
#group ⇒ Object
group <group name> Similar to “gid” but uses the GID of group name <group name> from /etc/group.
-
#log ⇒ Object
log <address> <facility> [max level [min level]] Adds a global syslog server.
-
#maxconn ⇒ Object
maxconn <number> Sets the maximum per-process number of concurrent connections to <number>.
-
#maxpipes ⇒ Object
maxpipes <number> Sets the maximum per-process number of pipes to <number>.
-
#nbproc ⇒ Object
nbproc <number> Creates <number> processes when going daemon.
-
#node ⇒ Object
node <name> Only letters, digits, hyphen and underscore are allowed, like in DNS names.
-
#noepoll ⇒ Object
noepoll Disables the use of the “epoll” event polling system on Linux.
-
#nokqueue ⇒ Object
nokqueue Disables the use of the “kqueue” event polling system on BSD.
-
#nopoll ⇒ Object
nopoll Disables the use of the “poll” event polling system.
-
#nosepoll ⇒ Object
nosepoll Disables the use of the “speculative epoll” event polling system on Linux.
-
#nosplice ⇒ Object
nosplice Disables the use of kernel tcp splicing between sockets on Linux.
-
#pidfile ⇒ Object
pidfile <pidfile> Writes pids of all daemons into file <pidfile>.
-
#quiet ⇒ Object
quiet Do not display any message during startup.
-
#spread_checks ⇒ Object
spread-checks <0..50, in percent> Sometimes it is desirable to avoid sending health checks to servers at exact intervals, for instance when many logical servers are located on the same physical server.
-
#stats_maxconn ⇒ Object
stats maxconn <connections> By default, the stats socket is limited to 10 concurrent connections.
-
#stats_socket ⇒ Object
stats socket <path> [(uid | user) <uid>] [(gid | group) <gid>] [mode <mode>] [level <level>].
-
#stats_timeout ⇒ Object
stats timeout <timeout, in milliseconds> The default timeout on the stats socket is set to 10 seconds.
-
#tune_bufsize ⇒ Object
tune.bufsize <number> Sets the buffer size to this size (in bytes).
-
#tune_chksize ⇒ Object
tune.chksize <number> Sets the check buffer size to this size (in bytes).
-
#tune_maxaccept ⇒ Object
tune.maxaccept <number> Sets the maximum number of consecutive accepts that a process may perform on a single wake up.
-
#tune_maxpollevents ⇒ Object
tune.maxpollevents <number> Sets the maximum amount of events that can be processed at once in a call to the polling system.
-
#tune_maxrewrite ⇒ Object
tune.maxrewrite <number> Sets the reserved buffer space to this size in bytes.
-
#tune_rcvbuf_client ⇒ Object
tune.rcvbuf.client <number> Forces the kernel socket receive buffer size on the client or the server side to the specified value in bytes.
-
#tune_rcvbuf_server ⇒ Object
tune.rcvbuf.server <number> Forces the kernel socket receive buffer size on the client or the server side to the specified value in bytes.
-
#tune_sndbuf_client ⇒ Object
tune.sndbuf.client <number> Forces the kernel socket send buffer size on the client or the server side to the specified value in bytes.
-
#tune_sndbuf_server ⇒ Object
tune.sndbuf.server <number> Forces the kernel socket send buffer size on the client or the server side to the specified value in bytes.
-
#uid ⇒ Object
uid <number> Changes the process’ user ID to <number>.
-
#ulimit_n ⇒ Object
ulimit-n <number> Sets the maximum number of per-process file-descriptors to <number>.
-
#unix_bind ⇒ Object
unix-bind [ prefix <prefix> ] [ mode <mode> ] [ user <user> ] [ uid <uid> ] [ group <group> ] [ gid <gid> ].
-
#user ⇒ Object
user <user name> Similar to “uid” but uses the UID of user name <user name> from /etc/passwd.
Instance Method Summary collapse
-
#config ⇒ Object
Compile the HAproxy global configuration.
-
#initialize ⇒ RhaproxyGlobal
constructor
Returns a new RhaproxyGlobal Object.
Constructor Details
#initialize ⇒ RhaproxyGlobal
Returns a new RhaproxyGlobal Object
425 426 |
# File 'lib/rhaproxy/global.rb', line 425 def initialize() end |
Instance Attribute Details
#chroot ⇒ Object
chroot <jail dir>
Changes current directory to <jail dir> and performs a chroot() there before
dropping privileges. This increases the security level in case an unknown
vulnerability would be exploited, since it would make it very hard for the
attacker to exploit the system. This only works when the process is started
with superuser privileges. It is important to ensure that <jail_dir> is both
empty and unwritable to anyone.
28 29 30 |
# File 'lib/rhaproxy/global.rb', line 28 def chroot @chroot end |
#daemon ⇒ Object
daemon
Makes the process fork into background. This is the recommended mode of
operation. It is equivalent to the command line "-D" argument. It can be
disabled by the command line "-db" argument.
36 37 38 |
# File 'lib/rhaproxy/global.rb', line 36 def daemon @daemon end |
#debug ⇒ Object
debug
Enables debug mode which dumps to stdout all exchanges, and disables forking
into background. It is the equivalent of the command-line argument "-d". It
should never be used in a production configuration since it may prevent full
system startup.
413 414 415 |
# File 'lib/rhaproxy/global.rb', line 413 def debug @debug end |
#description ⇒ Object
description <text>
Add a text that describes the instance.
Please note that it is required to escape certain characters (# for example)
and this text is inserted into a html page so you should avoid using
"<" and ">" characters.
197 198 199 |
# File 'lib/rhaproxy/global.rb', line 197 def description @description end |
#gid ⇒ Object
gid <number>
Changes the process' group ID to <number>. It is recommended that the group
ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
be started with a user belonging to this group, or with superuser privileges.
See also "group" and "uid".
45 46 47 |
# File 'lib/rhaproxy/global.rb', line 45 def gid @gid end |
#group ⇒ Object
group <group name>
Similar to "gid" but uses the GID of group name <group name> from /etc/group.
See also "gid" and "user".
52 53 54 |
# File 'lib/rhaproxy/global.rb', line 52 def group @group end |
#log ⇒ Object
log <address> <facility> [max level [min level]]
Adds a global syslog server. Up to two global servers can be defined. They
will receive logs for startups and exits, as well as all logs from proxies
configured with "log global".
<address> can be one of:
- An IPv4 address optionally followed by a colon and a UDP port. If
no port is specified, 514 is used by default (the standard syslog
port).
- A filesystem path to a UNIX domain socket, keeping in mind
considerations for chroot (be sure the path is accessible inside
the chroot) and uid/gid (be sure the path is appropriately
writeable).
<facility> must be one of the 24 standard syslog facilities :
kern user mail daemon auth syslog lpr news
uucp cron auth2 ftp ntp audit alert cron2
local0 local1 local2 local3 local4 local5 local6 local7
An optional level can be specified to filter outgoing messages. By default,
all messages are sent. If a maximum level is specified, only messages with a
severity at least as important as this level will be sent. An optional minimum
level can be specified. If it is set, logs emitted with a more severe level
than this one will be capped to this level. This is used to avoid sending
"emerg" messages on all terminals on some default syslog configurations.
Eight levels are known :
emerg alert crit err warning notice info debug
87 88 89 |
# File 'lib/rhaproxy/global.rb', line 87 def log @log end |
#maxconn ⇒ Object
maxconn <number>
Sets the maximum per-process number of concurrent connections to <number>. It
is equivalent to the command-line argument "-n". Proxies will stop accepting
connections when this limit is reached. The "ulimit-n" parameter is
automatically adjusted according to this value. See also "ulimit-n".
223 224 225 |
# File 'lib/rhaproxy/global.rb', line 223 def maxconn @maxconn end |
#maxpipes ⇒ Object
maxpipes <number>
Sets the maximum per-process number of pipes to <number>. Currently, pipes
are only used by kernel-based tcp splicing. Since a pipe contains two file
descriptors, the "ulimit-n" value will be increased accordingly. The default
value is maxconn/4, which seems to be more than enough for most heavy usages.
The splice code dynamically allocates and releases pipes, and can fall back
to standard copy, so setting this value too low may only impact performance.
234 235 236 |
# File 'lib/rhaproxy/global.rb', line 234 def maxpipes @maxpipes end |
#nbproc ⇒ Object
nbproc <number>
Creates <number> processes when going daemon. This requires the "daemon"
mode. By default, only one process is created, which is the recommended mode
of operation. For systems limited to small sets of file descriptors per
process, it may be needed to fork multiple daemons. USING MULTIPLE PROCESSES
IS HARDER TO DEBUG AND IS REALLY DISCOURAGED. See also "daemon".
97 98 99 |
# File 'lib/rhaproxy/global.rb', line 97 def nbproc @nbproc end |
#node ⇒ Object
node <name>
Only letters, digits, hyphen and underscore are allowed, like in DNS names.
This statement is useful in HA configurations where two or more processes or
servers share the same IP address. By setting a different node-name on all
nodes, it becomes easy to immediately spot what server is handling the
traffic.
187 188 189 |
# File 'lib/rhaproxy/global.rb', line 187 def node @node end |
#noepoll ⇒ Object
noepoll
Disables the use of the "epoll" event polling system on Linux. It is
equivalent to the command-line argument "-de". The next polling system
used will generally be "poll". See also "nosepoll", and "nopoll".
242 243 244 |
# File 'lib/rhaproxy/global.rb', line 242 def noepoll @noepoll end |
#nokqueue ⇒ Object
nokqueue
Disables the use of the "kqueue" event polling system on BSD. It is
equivalent to the command-line argument "-dk". The next polling system
used will generally be "poll". See also "nopoll".
250 251 252 |
# File 'lib/rhaproxy/global.rb', line 250 def nokqueue @nokqueue end |
#nopoll ⇒ Object
nopoll
Disables the use of the "poll" event polling system. It is equivalent to the
command-line argument "-dp". The next polling system used will be "select".
It should never be needed to disable "poll" since it's available on all
platforms supported by HAProxy. See also "nosepoll", and "nopoll" and
"nokqueue".
260 261 262 |
# File 'lib/rhaproxy/global.rb', line 260 def nopoll @nopoll end |
#nosepoll ⇒ Object
nosepoll
Disables the use of the "speculative epoll" event polling system on Linux. It
is equivalent to the command-line argument "-ds". The next polling system
used will generally be "epoll". See also "nosepoll", and "nopoll".
268 269 270 |
# File 'lib/rhaproxy/global.rb', line 268 def nosepoll @nosepoll end |
#nosplice ⇒ Object
nosplice
Disables the use of kernel tcp splicing between sockets on Linux. It is
equivalent to the command line argument "-dS". Data will then be copied
using conventional and more portable recv/send calls. Kernel tcp splicing is
limited to some very recent instances of kernel 2.6. Most versions between
2.6.25 and 2.6.28 are buggy and will forward corrupted data, so they must not
be used. This option makes it easier to globally disable kernel splicing in
case of doubt. See also "option splice-auto", "option splice-request" and
"option splice-response".
281 282 283 |
# File 'lib/rhaproxy/global.rb', line 281 def nosplice @nosplice end |
#pidfile ⇒ Object
pidfile <pidfile>
Writes pids of all daemons into file <pidfile>. This option is equivalent to
the "-p" command line argument. The file must be accessible to the user
starting the process. See also "daemon".
105 106 107 |
# File 'lib/rhaproxy/global.rb', line 105 def pidfile @pidfile end |
#quiet ⇒ Object
quiet
Do not display any message during startup. It is equivalent to the command-
line argument "-q".
420 421 422 |
# File 'lib/rhaproxy/global.rb', line 420 def quiet @quiet end |
#spread_checks ⇒ Object
spread-checks <0..50, in percent>
Sometimes it is desirable to avoid sending health checks to servers at exact
intervals, for instance when many logical servers are located on the same
physical server. With the help of this parameter, it becomes possible to add
some randomness in the check interval between 0 and +/- 50%. A value between
2 and 5 seems to show good results. The default value remains at 0.
291 292 293 |
# File 'lib/rhaproxy/global.rb', line 291 def spread_checks @spread_checks end |
#stats_maxconn ⇒ Object
stats maxconn <connections>
By default, the stats socket is limited to 10 concurrent connections. It is
possible to change this value with "stats maxconn".
176 177 178 |
# File 'lib/rhaproxy/global.rb', line 176 def stats_maxconn @stats_maxconn end |
#stats_socket ⇒ Object
stats socket <path> [(uid | user) <uid>] [(gid | group) <gid>] [mode <mode>]
[level <level>]
Creates a UNIX socket in stream mode at location <path>. Any previously
existing socket will be backed up then replaced. Connections to this socket
will return various statistics outputs and even allow some commands to be
issued. Please consult section 9.2 "Unix Socket commands" for more details.
An optional "level" parameter can be specified to restrict the nature of
the commands that can be issued on the socket :
- "user" is the least privileged level ; only non-sensitive stats can be
read, and no change is allowed. It would make sense on systems where it
is not easy to restrict access to the socket.
- "operator" is the default level and fits most common uses. All data can
be read, and only non-sensible changes are permitted (eg: clear max
counters).
- "admin" should be used with care, as everything is permitted (eg: clear
all counters).
On platforms which support it, it is possible to restrict access to this
socket by specifying numerical IDs after "uid" and "gid", or valid user and
group names after the "user" and "group" keywords. It is also possible to
restrict permissions on the socket by passing an octal value after the "mode"
keyword (same syntax as chmod). Depending on the platform, the permissions on
the socket will be inherited from the directory which hosts it, or from the
user the process is started with.
161 162 163 |
# File 'lib/rhaproxy/global.rb', line 161 def stats_socket @stats_socket end |
#stats_timeout ⇒ Object
stats timeout <timeout, in milliseconds>
The default timeout on the stats socket is set to 10 seconds. It is possible
to change this value with "stats timeout". The value must be passed in
milliseconds, or be suffixed by a time unit among { us, ms, s, m, h, d }.
169 170 171 |
# File 'lib/rhaproxy/global.rb', line 169 def stats_timeout @stats_timeout end |
#tune_bufsize ⇒ Object
tune.bufsize <number>
Sets the buffer size to this size (in bytes). Lower values allow more
sessions to coexist in the same amount of RAM, and higher values allow some
applications with very large cookies to work. The default value is 16384 and
can be changed at build time. It is strongly recommended not to change this
from the default value, as very low values will break some services such as
statistics, and values larger than default size will increase memory usage,
possibly causing the system to run out of memory. At least the global maxconn
parameter should be decreased by the same factor as this one is increased.
304 305 306 |
# File 'lib/rhaproxy/global.rb', line 304 def tune_bufsize @tune_bufsize end |
#tune_chksize ⇒ Object
tune.chksize <number>
Sets the check buffer size to this size (in bytes). Higher values may help
find string or regex patterns in very large pages, though doing so may imply
more memory and CPU usage. The default value is 16384 and can be changed at
build time. It is not recommended to change this value, but to use better
checks whenever possible.
314 315 316 |
# File 'lib/rhaproxy/global.rb', line 314 def tune_chksize @tune_chksize end |
#tune_maxaccept ⇒ Object
tune.maxaccept <number>
Sets the maximum number of consecutive accepts that a process may perform on
a single wake up. High values give higher priority to high connection rates,
while lower values give higher priority to already established connections.
This value is limited to 100 by default in single process mode. However, in
multi-process mode (nbproc > 1), it defaults to 8 so that when one process
wakes up, it does not take all incoming connections for itself and leaves a
part of them to other processes. Setting this value to -1 completely disables
the limitation. It should normally not be needed to tweak this value.
327 328 329 |
# File 'lib/rhaproxy/global.rb', line 327 def tune_maxaccept @tune_maxaccept end |
#tune_maxpollevents ⇒ Object
tune.maxpollevents <number>
Sets the maximum amount of events that can be processed at once in a call to
the polling system. The default value is adapted to the operating system. It
has been noticed that reducing it below 200 tends to slightly decrease
latency at the expense of network bandwidth, and increasing it above 200
tends to trade latency for slightly increased bandwidth.
337 338 339 |
# File 'lib/rhaproxy/global.rb', line 337 def tune_maxpollevents @tune_maxpollevents end |
#tune_maxrewrite ⇒ Object
tune.maxrewrite <number>
Sets the reserved buffer space to this size in bytes. The reserved space is
used for header rewriting or appending. The first reads on sockets will never
fill more than bufsize-maxrewrite. Historically it has defaulted to half of
bufsize, though that does not make much sense since there are rarely large
numbers of headers to add. Setting it too high prevents processing of large
requests or responses. Setting it too low prevents addition of new headers
to already large requests or to POST requests. It is generally wise to set it
to about 1024. It is automatically readjusted to half of bufsize if it is
larger than that. This means you don't have to worry about it when changing
bufsize.
352 353 354 |
# File 'lib/rhaproxy/global.rb', line 352 def tune_maxrewrite @tune_maxrewrite end |
#tune_rcvbuf_client ⇒ Object
tune.rcvbuf.client <number>
Forces the kernel socket receive buffer size on the client or the server side
to the specified value in bytes. This value applies to all TCP/HTTP frontends
and backends. It should normally never be set, and the default size (0) lets
the kernel autotune this value depending on the amount of available memory.
However it can sometimes help to set it to very low values (eg: 4096) in
order to save kernel memory by preventing it from buffering too large amounts
of received data. Lower values will significantly increase CPU usage though.
363 364 365 |
# File 'lib/rhaproxy/global.rb', line 363 def tune_rcvbuf_client @tune_rcvbuf_client end |
#tune_rcvbuf_server ⇒ Object
tune.rcvbuf.server <number>
Forces the kernel socket receive buffer size on the client or the server side
to the specified value in bytes. This value applies to all TCP/HTTP frontends
and backends. It should normally never be set, and the default size (0) lets
the kernel autotune this value depending on the amount of available memory.
However it can sometimes help to set it to very low values (eg: 4096) in
order to save kernel memory by preventing it from buffering too large amounts
of received data. Lower values will significantly increase CPU usage though.
374 375 376 |
# File 'lib/rhaproxy/global.rb', line 374 def tune_rcvbuf_server @tune_rcvbuf_server end |
#tune_sndbuf_client ⇒ Object
tune.sndbuf.client <number>
Forces the kernel socket send buffer size on the client or the server side to
the specified value in bytes. This value applies to all TCP/HTTP frontends
and backends. It should normally never be set, and the default size (0) lets
the kernel autotune this value depending on the amount of available memory.
However it can sometimes help to set it to very low values (eg: 4096) in
order to save kernel memory by preventing it from buffering too large amounts
of received data. Lower values will significantly increase CPU usage though.
Another use case is to prevent write timeouts with extremely slow clients due
to the kernel waiting for a large part of the buffer to be read before
notifying haproxy again.
389 390 391 |
# File 'lib/rhaproxy/global.rb', line 389 def tune_sndbuf_client @tune_sndbuf_client end |
#tune_sndbuf_server ⇒ Object
tune.sndbuf.server <number>
Forces the kernel socket send buffer size on the client or the server side to
the specified value in bytes. This value applies to all TCP/HTTP frontends
and backends. It should normally never be set, and the default size (0) lets
the kernel autotune this value depending on the amount of available memory.
However it can sometimes help to set it to very low values (eg: 4096) in
order to save kernel memory by preventing it from buffering too large amounts
of received data. Lower values will significantly increase CPU usage though.
Another use case is to prevent write timeouts with extremely slow clients due
to the kernel waiting for a large part of the buffer to be read before
notifying haproxy again.
404 405 406 |
# File 'lib/rhaproxy/global.rb', line 404 def tune_sndbuf_server @tune_sndbuf_server end |
#uid ⇒ Object
uid <number>
Changes the process' user ID to <number>. It is recommended that the user ID
is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
be started with superuser privileges in order to be able to switch to another
one. See also "gid" and "user".
114 115 116 |
# File 'lib/rhaproxy/global.rb', line 114 def uid @uid end |
#ulimit_n ⇒ Object
ulimit-n <number>
Sets the maximum number of per-process file-descriptors to <number>. By
default, it is automatically computed, so it is recommended not to use this
option.
122 123 124 |
# File 'lib/rhaproxy/global.rb', line 122 def ulimit_n @ulimit_n end |
#unix_bind ⇒ Object
unix-bind [ prefix <prefix> ] [ mode <mode> ] [ user <user> ] [ uid <uid> ]
[ group <group> ] [ gid <gid> ]
Fixes common settings to UNIX listening sockets declared in "bind" statements.
This is mainly used to simplify declaration of those UNIX sockets and reduce
the risk of errors, since those settings are most commonly required but are
also process-specific. The <prefix> setting can be used to force all socket
path to be relative to that directory. This might be needed to access another
component's chroot. Note that those paths are resolved before haproxy chroots
itself, so they are absolute. The <mode>, <user>, <uid>, <group> and <gid>
all have the same meaning as their homonyms used by the "bind" statement. If
both are specified, the "bind" statement has priority, meaning that the
"unix-bind" settings may be seen as process-wide default settings.
214 215 216 |
# File 'lib/rhaproxy/global.rb', line 214 def unix_bind @unix_bind end |
#user ⇒ Object
user <user name>
Similar to "uid" but uses the UID of user name <user name> from /etc/passwd.
See also "uid" and "group".
129 130 131 |
# File 'lib/rhaproxy/global.rb', line 129 def user @user end |
Instance Method Details
#config ⇒ Object
Compile the HAproxy global configuration
431 432 433 434 435 436 437 |
# File 'lib/rhaproxy/global.rb', line 431 def config conf = option_string() return conf end |