----------------------
HAProxy
Configuration Manual
----------------------
version 1.4.24
willy tarreau
2013/06/17
This document covers the configuration language as implemented in the version
specified above. It does not provide any hint, example or advice. For such
documentation, please refer to the Reference Manual or the Architecture Manual.
The summary below is meant to help you search sections by name and navigate
through the document.
Note to documentation contributors :
This document is formated with 80 columns per line, with even number of
spaces for indentation and without tabs. Please follow these rules strictly
so that it remains easily printable everywhere. If a line needs to be
printed verbatim and does not fit, please end each line with a backslash
('\') and continue on next line. If you add sections, please update the
summary below for easier searching.
Summary
-------
1. Quick reminder about HTTP
1.1. The HTTP transaction model
1.2. HTTP request
1.2.1. The Request line
1.2.2. The request headers
1.3. HTTP response
1.3.1. The Response line
1.3.2. The response headers
2. Configuring HAProxy
2.1. Configuration file format
2.2. Time format
2.3. Examples
3. Global parameters
3.1. Process management and security
3.2. Performance tuning
3.3. Debugging
3.4. Userlists
4. Proxies
4.1. Proxy keywords matrix
4.2. Alphabetically sorted keywords reference
5. Server and default-server options
6. HTTP header manipulation
7. Using ACLs and pattern extraction
7.1. Matching integers
7.2. Matching strings
7.3. Matching regular expressions (regexes)
7.4. Matching IPv4 addresses
7.5. Available matching criteria
7.5.1. Matching at Layer 4 and below
7.5.2. Matching contents at Layer 4
7.5.3. Matching at Layer 7
7.6. Pre-defined ACLs
7.7. Using ACLs to form conditions
7.8. Pattern extraction
8. Logging
8.1. Log levels
8.2. Log formats
8.2.1. Default log format
8.2.2. TCP log format
8.2.3. HTTP log format
8.3. Advanced logging options
8.3.1. Disabling logging of external tests
8.3.2. Logging before waiting for the session to terminate
8.3.3. Raising log level upon errors
8.3.4. Disabling logging of successful connections
8.4. Timing events
8.5. Session state at disconnection
8.6. Non-printable characters
8.7. Capturing HTTP cookies
8.8. Capturing HTTP headers
8.9. Examples of logs
9. Statistics and monitoring
9.1. CSV format
9.2. Unix Socket commands
1. Quick reminder about HTTP
----------------------------
When haproxy is running in HTTP mode, both the request and the response are
fully analyzed and indexed, thus it becomes possible to build matching criteria
on almost anything found in the contents.
However, it is important to understand how HTTP requests and responses are
formed, and how HAProxy decomposes them. It will then become easier to write
correct rules and to debug existing configurations.
1.1. The HTTP transaction model
-------------------------------
The HTTP protocol is transaction-driven. This means that each request will lead
to one and only one response. Traditionally, a TCP connection is established
from the client to the server, a request is sent by the client on the
connection, the server responds and the connection is closed. A new request
will involve a new connection :
[CON1] [REQ1] ... [RESP1] [CLO1] [CON2] [REQ2] ... [RESP2] [CLO2] ...
In this mode, called the "HTTP close" mode, there are as many connection
establishments as there are HTTP transactions. Since the connection is closed
by the server after the response, the client does not need to know the content
length.
Due to the transactional nature of the protocol, it was possible to improve it
to avoid closing a connection between two subsequent transactions. In this mode
however, it is mandatory that the server indicates the content length for each
response so that the client does not wait indefinitely. For this, a special
header is used: "Content-length". This mode is called the "keep-alive" mode :
[CON] [REQ1] ... [RESP1] [REQ2] ... [RESP2] [CLO] ...
Its advantages are a reduced latency between transactions, and less processing
power required on the server side. It is generally better than the close mode,
but not always because the clients often limit their concurrent connections to
a smaller value.
A last improvement in the communications is the pipelining mode. It still uses
keep-alive, but the client does not wait for the first response to send the
second request. This is useful for fetching large number of images composing a
page :
[CON] [REQ1] [REQ2] ... [RESP1] [RESP2] [CLO] ...
This can obviously have a tremendous benefit on performance because the network
latency is eliminated between subsequent requests. Many HTTP agents do not
correctly support pipelining since there is no way to associate a response with
the corresponding request in HTTP. For this reason, it is mandatory for the
server to reply in the exact same order as the requests were received.
By default HAProxy operates in a tunnel-like mode with regards to persistent
connections: for each connection it processes the first request and forwards
everything else (including additional requests) to selected server. Once
established, the connection is persisted both on the client and server
sides. Use "option http-server-close" to preserve client persistent connections
while handling every incoming request individually, dispatching them one after
another to servers, in HTTP close mode. Use "option httpclose" to switch both
sides to HTTP close mode. "option forceclose" and "option
http-pretend-keepalive" help working around servers misbehaving in HTTP close
mode.
1.2. HTTP request
-----------------
First, let's consider this HTTP request :
Line Contents
number
1 GET /serv/login.php?lang=en&profile=2 HTTP/1.1
2 Host: www.mydomain.com
3 User-agent: my small browser
4 Accept: image/jpeg, image/gif
5 Accept: image/png
1.2.1. The Request line
-----------------------
Line 1 is the "request line". It is always composed of 3 fields :
- a METHOD : GET
- a URI : /serv/login.php?lang=en&profile=2
- a version tag : HTTP/1.1
All of them are delimited by what the standard calls LWS (linear white spaces),
which are commonly spaces, but can also be tabs or line feeds/carriage returns
followed by spaces/tabs. The method itself cannot contain any colon (':') and
is limited to alphabetic letters. All those various combinations make it
desirable that HAProxy performs the splitting itself rather than leaving it to
the user to write a complex or inaccurate regular expression.
The URI itself can have several forms :
- A "relative URI" :
/serv/login.php?lang=en&profile=2
It is a complete URL without the host part. This is generally what is
received by servers, reverse proxies and transparent proxies.
- An "absolute URI", also called a "URL" :
http://192.168.0.12:8080/serv/login.php?lang=en&profile=2
It is composed of a "scheme" (the protocol name followed by '://'), a host
name or address, optionally a colon (':') followed by a port number, then
a relative URI beginning at the first slash ('/') after the address part.
This is generally what proxies receive, but a server supporting HTTP/1.1
must accept this form too.
- a star ('*') : this form is only accepted in association with the OPTIONS
method and is not relayable. It is used to inquiry a next hop's
capabilities.
-
没有合适的资源?快使用搜索试试~ 我知道了~
haproxy-1.4.24.tar.gz
5星 · 超过95%的资源 需积分: 12 513 下载量 138 浏览量
2014-03-21
13:50:32
上传
评论
收藏 817KB GZ 举报
温馨提示
共302个文件
h:98个
c:68个
cfg:53个
haproxy-1.4.24.tar.gz ,linux中负载均衡调度器,keepalived+haproxy实现故障转移+负载均衡服务。
资源推荐
资源详情
资源评论
收起资源包目录
haproxy-1.4.24.tar.gz (302个子文件)
haproxy.1 6KB
Makefile.bsd 5KB
proto_http.c 263KB
cfgparse.c 187KB
dumpstats.c 98KB
session.c 54KB
checks.c 52KB
acl.c 43KB
halog.c 43KB
backend.c 42KB
proto_tcp.c 34KB
haproxy.c 33KB
stream_sock.c 33KB
standard.c 24KB
proxy.c 23KB
client.c 21KB
ev_sepoll.c 19KB
lb_fwrr.c 16KB
proto_uxst.c 16KB
pattern.c 15KB
test_hashes.c 15KB
buffers.c 13KB
lb_chash.c 13KB
stream_interface.c 11KB
log.c 11KB
filltab25.c 10KB
uri_hash.c 9KB
rbtree.c 9KB
ev_epoll.c 9KB
lb_fwlc.c 8KB
task.c 8KB
time.c 8KB
stick_table.c 8KB
fgets2.c 8KB
lb_map.c 7KB
eb64tree.c 7KB
eb32tree.c 7KB
ebpttree.c 7KB
uri_auth.c 6KB
ev_kqueue.c 6KB
ev_select.c 6KB
protocols.c 6KB
ev_poll.c 6KB
ip-hash.c 6KB
test_pools.c 6KB
queue.c 6KB
auth.c 5KB
iprange.c 5KB
memory.c 5KB
base64.c 5KB
appsession.c 4KB
fd.c 4KB
signal.c 3KB
freq_ctr.c 3KB
ebmbtree.c 3KB
regex.c 3KB
sessionhash.c 3KB
ebistree.c 2KB
pipe.c 2KB
ebsttree.c 2KB
hdr_idx.c 2KB
ebimtree.c 2KB
sessionhash_test.c 1KB
cttproxy.c 1KB
base64rev-gen.c 1KB
reset.c 1KB
ebtree.c 1KB
server.c 1KB
testinet.c 629B
test.c 270B
test-sched.cfg 374KB
test-check-cpu.cfg 75KB
test-fsm.cfg 14KB
url-switching.cfg 4KB
acl-content-sw.cfg 4KB
examples.cfg 4KB
auth.cfg 3KB
haproxy.cfg 2KB
test-check-expect.cfg 2KB
test-disable-404.cfg 2KB
test-retries.cfg 2KB
tarpit.cfg 2KB
content-sw-sample.cfg 2KB
test-fwlc.cfg 2KB
test-fwrr.cfg 2KB
cttproxy-src.cfg 2KB
test-inspect-smtp.cfg 2KB
basic-test.cfg 1KB
test-redirect.cfg 1KB
backup-all-sh.cfg 1KB
backup-second-sh.cfg 1KB
option-http_proxy.cfg 1KB
build.cfg 1KB
test-redir.cfg 1KB
test-inspect-ssl.cfg 1KB
backup-all.cfg 1KB
backup-second.cfg 1KB
backup-first.cfg 1KB
defaults.cfg 1KB
httpterm-basic.cfg 1KB
共 302 条
- 1
- 2
- 3
- 4
winner_reset
- 粉丝: 30
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- vscode配置c/c 环境教程
- vscode配置c/c 环境教程
- 基于matlab实现电磁优化计算功能,进行线型规划优化电磁设计.rar
- 基于matlab实现带精英策略的非支配排序遗传算法matlab 源码.rar
- 基于matlab实现差分进化算法,最新的用于替代遗传算法,是以后的主要发展方法.rar
- VSCode配置c/c++环境教程.md
- 基于matlab实现标准合作型协同进化遗传算法matlab源程序
- 七下人教.zip
- 基于matlab实现本份代码能对图像进行gabor滤波处理,结合指纹方向图以及指纹沟壑频率特性,对指纹图像进行增强.rar
- 基于matlab实现RBM神经网络实现了手写数字体识别的GUI程序.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页