haproxy 实用配置解析
2017-10-31 22:25
239 查看
LB Cluster:
四层: lvs, nginx(stream), haproxy(mode tcp)
七层: http: nginx(http), haproxy(mode http), httpd…
HAProxy: http://www.haproxy.org
文档: https://cbonte.github.io/haproxy-dconv/
Haproxy功能
HAProxy是TCP / HTTP反向代理服务器,尤其适合于高可用
性环境
可以针对HTTP请求添加cookie,进行路由后端服务器
可平衡负载至后端服务器,并支持持久连接
支持基于cookie进行调度
支持所有主服务器故障切换至备用服务器
支持专用端口实现监控服务
支持不影响现有连接情况下停止接受新连接请求
可以在双向添加,修改或删除HTTP报文首部
支持基于pattern实现连接请求的访问控制
通过特定的URI为授权用户提供详细的状态信息
支持http反向代理
支持动态程序的反向代理
支持基于数据库的反向代理
配置段:
global:全局配置段
进程及安全配置相关的参数
性能调整相关参数
Debug参数
proxies:代理配置段
defaults:为frontend, backend, listen提供默认配置
fronted:前端,相当于nginx, server {}
backend:后端,相当于nginx, upstream {}
listen:同时拥有前端和后端,适用于一对一环境
未完待续。。。。。。
四层: lvs, nginx(stream), haproxy(mode tcp)
七层: http: nginx(http), haproxy(mode http), httpd…
HAProxy: http://www.haproxy.org
文档: https://cbonte.github.io/haproxy-dconv/
Haproxy功能
HAProxy是TCP / HTTP反向代理服务器,尤其适合于高可用
性环境
可以针对HTTP请求添加cookie,进行路由后端服务器
可平衡负载至后端服务器,并支持持久连接
支持基于cookie进行调度
支持所有主服务器故障切换至备用服务器
支持专用端口实现监控服务
支持不影响现有连接情况下停止接受新连接请求
可以在双向添加,修改或删除HTTP报文首部
支持基于pattern实现连接请求的访问控制
通过特定的URI为授权用户提供详细的状态信息
支持http反向代理
支持动态程序的反向代理
支持基于数据库的反向代理
配置段:
global:全局配置段
进程及安全配置相关的参数
性能调整相关参数
Debug参数
proxies:代理配置段
defaults:为frontend, backend, listen提供默认配置
fronted:前端,相当于nginx, server {}
backend:后端,相当于nginx, upstream {}
listen:同时拥有前端和后端,适用于一对一环境
defaults mode http group haproxy daemon # turn on stats unix socket stats socket /var/lib/haproxy/stats #--------------------------------------------------------------------- # common defaults that all the 'listen' and 'backend' sections will # use if not designated in their block #--------------------------------------------------------------------- defaults mode http log global option httplog option dontlognull option http-server-close option forwardfor except 127.0.0.0/8 option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 #--------------------------------------------------------------------- # main frontend which proxys to the backends #--------------------------------------------------------------------- frontend http 192.168.1.33:80 stats enable stats uri /hastats stats auth ha1:centos #stats auth ha2:mage default_backend webs backend webs balance roundrobin option httpchk GET /index.html HTTP/1.1\r\nhost: cookie SRV insert nocache server web1 192.168.10.30:80 check server web2 192.168.10.32:80 check maxconn 5000 #frontend http 192.168.1.33:80 #frontend main *:5000 # acl url_static path_beg -i /static /images /javascript /stylesheets # acl url_static path_end -i .jpg .gif .png .css .js # use_backend static if url_static # default_backend app #--------------------------------------------------------------------- # static backend for serving up images, stylesheets and such #--------------------------------------------------------------------- #backend static # balance roundrobin # server static 127.0.0.1:4331 check #--------------------------------------------------------------------- # round robin balancing between the various backends #--------------------------------------------------------------------- #backend app # balance roundrobin # server app1 127.0.0.1:5001 check # server app2 127.0.0.1:5002 check # server app3 127.0.0.1:5003 check # server app4 127.0.0.1:5004 check`这里写代码片`
未完待续。。。。。。
相关文章推荐
- Fckeditor的配置解析,较为实用
- haproxy 配置文件解析
- haproxy配置解析一
- haproxy学习笔记2:1.3.0的配置文件解析
- HAProxy官方文档1.4 解析:2 配置HAProxy
- haproxy之配置文件解析
- haproxy 配置文件解析及haproxy acl匹配规则
- HaProxy学习笔记3: 1.4.23的配置文件解析-examples.cfg
- 安装 HAProxy 配置负载均衡
- JDK的最实用简单配置
- 详细解析_Log4j_配置
- cocos2dx lua解析csv成lua配置文件,方便程序调用
- haproxy 安装和配置
- Linux 学习笔记_5_Linux引导流程解析_3_GRUB配置及Linux系统修复
- struts2的注解配置全面解析
- haproxy+keepalived配置haproxy反向代理的高可用
- 关于Nginx的配置文件解析
- udev解析及规则配置文件
- Django源码解析(五) URL配置
- 免备案\免审批号\廉价教你构建自己的网站\域名DNS解析\超实用的端口映射转发