This example will guide you through a simple IP based load balancing solution that handles ssl traffic.

The Configuration =

  • Load Balancer:  <192.168.0.2>  // will be our haproxy server
  • Web Server 1: <192.168.0.10>  // web application server 1
  • Web Server 2: <192.168.0.20>  // web application server 2
  • Admin Panel Port 8080: <192.168.0.2>  // Statistics Panel on port 8080

Web Server 1
Load Balancer   <
                                       Web Server 2

Step 1: Get and Install haproxy

We’ll be using the 1.3.17 src files to install haproxy. You can get them from http://haproxy.1wt.eu/

  1. wget http://haproxy.1wt.eu/download/1.3/src/haproxy-1.3.17.tar.gz
  2. cd haproxy-1.3.17
  3. make TARGET=linux26
  4. cp /path/to/haproxy-1.3.17/examples/haproxy.init /etc/init.d/haproxy
  5. chmod +x /etc/init.d/haproxy

We’re going to add a haproxy user and run it in a chroot jail. Be sure to read up on other security measures for your server.

  1. useradd haproxy
  2. mkdir /var/chroot/haproxy
  3. chown haproxy:haproxy /var/chroot/haproxy
  4. chmod 700 /var/chroot/haproxy

This will be a simple load balancing. The HAProxy server will listen to 1 IP and distribute to 2 servers.

  1. global
  2. maxconn     10000 # Total Max Connections.
  3. log     127.0.0.1   local0
  4. log     127.0.0.1   local1 notice
  5. daemon
  6. nbproc      1 # Number of processes
  7. user        haproxy
  8. group       haproxy
  9. chroot      /var/chroot/haproxy
  10. defaults
  11. log     global
  12. option      httplog
  13. mode        tcp
  14. clitimeout  60000
  15. srvtimeout  30000
  16. contimeout  4000
  17. retries     3
  18. redispatch
  19. option      httpclose
  20. listen  load_balanced   192.168.0.2:80,192.168.0.2:443
  21. balance     source
  22. option      ssl-hello-chk
  23. option      forwardfor
  24. server webserver1 192.168.0.10 weight 1 maxconn 5000 check
  25. server webserver2 192.168.0.20 weight 1 maxconn 5000 check
  26. listen  admin_stats 192.168.0.2:8080
  27. mode        http
  28. stats uri   /my_stats
  29. stats realm     Global\ statistics
  30. stats auth  username:password

Step 4: Configuring logging

Edit /etc/sysconfig/syslog

  1. SYSLOGD_OPTIONS=”-m 0 -r”

Installing haproxy load balancing for http and https--转载的更多相关文章

  1. gRPC Load Balancing

    gRPC Load Balancing 翻译自:https://grpc.io/blog/grpc-load-balancing/ 这是gRPC负载均衡的第一篇,后续会给出基于golang XDS服务 ...

  2. 【架构】How To Use HAProxy to Set Up MySQL Load Balancing

    How To Use HAProxy to Set Up MySQL Load Balancing Dec  2, 2013 MySQL, Scaling, Server Optimization U ...

  3. Load Balancing OpenSSH SFTP with HAProxy

    In my previous post I described how we setup a Ubuntu Server (12.0.4) as an OpenSSH SFTP server. In ...

  4. 负载均衡(Load Balancing)学习笔记(二)

    概述 文章负载均衡(Load Balancing)学习笔记(一) 讲述了负载均衡的一般性原理,本文继续介绍常见的实现负载均衡的方法. HTTP重定向 HTTP重定向服务器是一台普通的Web服务器,用户 ...

  5. 负载均衡(Load Balancing)学习笔记(一)

    概述 在分布式系统中,负载均衡(Load Balancing)是一种将任务分派到多个服务端进程的方法.例如,将一个HTTP请求派发到实际的Web服务器中执行的过程就涉及负载均衡的实现.一个HTTP请求 ...

  6. Elastic Load Balancing with Sticky Sessions

    Elastic Load Balancing with Sticky Sessions — Shlomo Swidler https://shlomoswidler.com/2010/04/elast ...

  7. Network Load Balancing Technical Overview--reference

    http://technet.microsoft.com/en-us/library/bb742455.aspx Abstract Network Load Balancing, a clusteri ...

  8. NGINX Load Balancing - HTTP Load Balancer

    This chapter describes how to use NGINX and NGINX Plus as a load balancer. Overview Load balancing a ...

  9. NGINX Docs | Load Balancing Apache Tomcat Servers with NGINX Open Source and NGINX Plus

    NGINX Docs | Load Balancing Apache Tomcat Servers with NGINX Open Source and NGINX Plushttps://docs. ...

随机推荐

  1. Media Queries简单案例一

    案例一: 1 <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...

  2. Python学习-3.Python的模块加载

    Python中使用import关键字进行模块加载. 先在Visual Studio中建立PythonModuleLoad项目作为演示. 1.同目录加载 建立SameFolder.py文件 写入代码: ...

  3. 浅析C# Dictionary实现原理

    目录 一.前言 二.理论知识 1.Hash算法 2.Hash桶算法 3.解决冲突算法 三.Dictionary实现 1. Entry结构体 2. 其它关键私有变量 3. Dictionary - Ad ...

  4. ASP.NET Core 装X利器SignalR:电子画板

    电子画板开发需求 教师端需求: 教师登录后能创建房间(教室) 学生加入房间后有通知提醒 教师能够解散房间 基本的画板功能   学生端需求: 能够切换不同在线的房间 能够收到新建房间的通知 能够收到房间 ...

  5. DataSet转换成List<>

    方法一: //DataSet转换成List<ArticleInfo> public List<ArticleInfo> GetArticleList(DataSet ds) { ...

  6. PaaS服务之路漫谈(三)

    此文已由作者尧飘海授权网易云社区发布. 欢迎访问网易云社区,了解更多网易技术产品运营经验. Monolithic架构在产品访问量很大的情况下,有可能常会导致整个产品迭代或升级过程不能按预期进行,或者上 ...

  7. 【转】目标检测之YOLO系列详解

    本文逐步介绍YOLO v1~v3的设计历程. YOLOv1基本思想 YOLO将输入图像分成SxS个格子,若某个物体 Ground truth 的中心位置的坐标落入到某个格子,那么这个格子就负责检测出这 ...

  8. hexo安装总结

    博客原文地址:Claiyre的个人博客 如需转载,请在文章开头注明原文地址 hexo真心是一个不错的东西呢,安装简单(然而对博主来说并不是这样,伤心脸),主题样式简洁优雅,还有多种选择. 流程如下 安 ...

  9. postgresql-数据库网络地址存储探索

    问题背景 数据库审核过程中发现有存储ip的字段类型为varchar(50).想到postgresql有专门的存储ip类型.然而存在即合理.所以主要对比varchar和inet存储ip的不同. 网络地址 ...

  10. Python sys os getpass 包的导入

    块的导入 导入一个py文件,解释器解释该py文件 导入一个包,解释器解释该包下的 init.py 文件 import module 直接导入模块 from module.xx.xx import xx ...