环境背景:CentOS 7.2

实验拓扑图:

实验配置:

静态服务器Nginx主机配置
#安装nginx,因为我本地有nginx的rpm包,所以直接安装的是本地的包
[root@localhost ~]# ls
anaconda-ks.cfg  Documents  f1  ha    issue.out  Music    nginx-1.10.0-1.el7.ngx.x86_64.rpm  out     phone     Public  s1       Templates  Videos
Desktop          Downloads  g1  haha  mail       mysh.sh  num                                passwd  Pictures  qq      shenfen  test
[root@localhost ~]# yum install ./nginx-1.10.0-1.el7.ngx.x86_64.rpm
Loaded plugins: fastestmirror, langpacks
Examining ./nginx-1.10.0-1.el7.ngx.x86_64.rpm: 1:nginx-1.10.0-1.el7.ngx.x86_64
./nginx-1.10.0-1.el7.ngx.x86_64.rpm: does not update installed package.
Error: Nothing to do
#配置主页信息
[root@localhost ~]# rm /usr/share/nginx/html/index.html
rm: remove regular file ‘/usr/share/nginx/html/index.html’? y
[root@localhost ~]# vim /usr/share/nginx/html/index.html<h1>Node2 Static Page</h1>
#启动nginx服务
[root@localhost ~]# nginx
[root@localhost ~]# ss -tnl
State      Recv-Q Send-Q                             Local Address:Port                                            Peer Address:Port
LISTEN     0      64                                             *:56300                                                      *:*
LISTEN     0      128                                            *:111                                                        *:*
LISTEN     0      128                                            *:80                                                         *:*
LISTEN     0      128                                            *:20048                                                      *:*
LISTEN     0      128                                            *:22                                                         *:*
LISTEN     0      128                                    127.0.0.1:631                                                        *:*
LISTEN     0      128                                            *:42681                                                      *:*
LISTEN     0      100                                    127.0.0.1:25                                                         *:*
[root@localhost ~]#
动态服务器Httpd+php主机配置
#yum安装httpd和php
[root@localhost ~]# yum install httpd php
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base                                                                                                                         | 3.6 kB  00:00:00
Determining fastest mirrors
Package httpd-2.4.6-40.el7.centos.x86_64 already installed and latest version
Package php-5.4.16-36.el7_1.x86_64 already installed and latest version
Nothing to do
#提供php测试页
[root@localhost ~]# vim /var/www/html/index.php <h1>Node1 Dynamic Server<h1>
<?phpphpinfo();
?>
#启动服务
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# ss -tnl
State      Recv-Q Send-Q                             Local Address:Port                                            Peer Address:Port
LISTEN     0      50                                             *:3306                                                       *:*
LISTEN     0      128                                            *:22                                                         *:*
LISTEN     0      128                                    127.0.0.1:631                                                        *:*
LISTEN     0      100                                    127.0.0.1:25                                                         *:*
LISTEN     0      128                                    127.0.0.1:6010                                                       *:*
LISTEN     0      64                                             *:44421                                                      *:*
LISTEN     0      64                                            :::40360                                                     :::*
LISTEN     0      128                                           :::80                                                        :::*
LISTEN     0      128                                           :::22                                                        :::*
LISTEN     0      128                                          ::1:631                                                       :::*
LISTEN     0      100                                          ::1:25                                                        :::*
LISTEN     0      128                                          ::1:6010                                                      :::*
[root@localhost ~]#
HAProxy主机配置
#yum安装haproxy
[root@localhost haproxy]# yum install haproxy
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package haproxy-1.5.14-3.el7.x86_64 already installed and latest version
Nothing to do
#修改配置文件62 #---------------------------------------------------------------------
#在frontend配置段做以下修改 63 frontend  main *:80        #将端口更改为8064     acl url_static       path_beg       -i /static /p_w_picpaths /javascript /stylesheets65     acl url_static       path_end       -i .jpg .gif .png .css .js66     acl dynamic          path_end       -i .php    #以.php结尾的定义为dynamic67     acl static           path_end       -i .html   #以.html结尾定义为static68     use_backend dyna            if dynamic        #如果url匹配到dynamic则调度至dyna69 #    use_backend static          if url_static    #如果url匹配到static则调度至static70     use_backend static          if static71     default_backend             static72 73 #---------------------------------------------------------------------74 # static backend for serving up p_w_picpaths, stylesheets and such75 #---------------------------------------------------------------------76 backend static   #定义后端主机10.1.53.11为static             78     server      web2  10.1.53.11:8079 backend dyna     #定义后端主机10.1.0.53为dyna80     server      web1  10.1.0.53:8081 82 #---------------------------------------------------------------------
#启动服务
[root@localhost haproxy]# systemctl start haproxy
[root@localhost haproxy]# ss -tnl
State      Recv-Q Send-Q                             Local Address:Port                                            Peer Address:Port
LISTEN     0      128                                            *:80                                                         *:*
LISTEN     0      128                                            *:22                                                         *:*
LISTEN     0      128                                    127.0.0.1:631                                                        *:*
LISTEN     0      100                                    127.0.0.1:25                                                         *:*
LISTEN     0      128                                    127.0.0.1:6010                                                       *:*
LISTEN     0      128                                           :::22                                                        :::*
LISTEN     0      128                                          ::1:631                                                       :::*
LISTEN     0      100                                          ::1:25                                                        :::*
LISTEN     0      128                                          ::1:6010                                                      :::*
[root@localhost haproxy]#
使用物理机访问测试,访问HAProxy主机

谢谢浏览...

转载于:https://blog.51cto.com/dashui/1874045

HAProxy实现动静分离相关推荐

  1. 高可用集群下的负载均衡(5):haproxy的动静分离与读写分离

    一.haproxy动静分离 实验环境: server2(haproxy):安装 haproxy server3(静态服务器):在apache的默认发布目录下创建一个 images目录,并放一张图片 s ...

  2. Haproxy实现负载均衡及相关配置(添加日志、设定自动刷新时间、控制访问、动静分离、读写分离)

    1.HAProxy简介 (1)HAProxy 是一款提供高可用性.负载均衡以及基于TCP(第四层)和HTTP(第七层)应用的代理软件,支持虚拟主机,它是免费.快速并且可靠的一种解决方案. HAProx ...

  3. mysql动静分离_haproxy的web服务负载均衡、动静分离、 MySQL服务负载均衡、状态监控...

    实验环境:基于centos6.6 haproxy-Server:172.16.249.98  hostname:node1 upsteram server1:172.16.249.100 hostna ...

  4. HAproxy七层负载均衡——访问控制、动静分离、读写分离实现过程详解

    实验环境 主机名 IP 服务 虚拟机server1 172.25.6.1 haproxy,httpd,服务端 虚拟机server2 172.25.6.2 httpd,php,客户端 虚拟机server ...

  5. haproxy访问控制与动静分离

    acl 语法: 1 acl  <acl_name>  <criterion> [flags] [operator] <value> acl_name:自定义的acl ...

  6. 基于HAproxy的web动静分离及输出状态检测页面

    一.简介 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代 理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAProxy特别适用于那些负载特大的web站点,这些站点通常又 ...

  7. HAProxy+apache实现web服务动静分离

    HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案. HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支 ...

  8. HAproxy负载均衡动静分离实现及配置详解

     HAproxy负载均衡动静分离实现及配置详解 HAproxy的介绍 HAProxy提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,支持虚拟主机,它是免费.快速并且可靠的一种解决方案.HAP ...

  9. LAMP+haproxy+varnish实现网站访问的动静分离及静态资源缓存

    原文  http://sohudrgon.blog.51cto.com/3088108/1601842 系统架构图: 主机规划列表: 全部的主机: CPU : Intel(R) Core(TM)i5- ...

最新文章

  1. 计算机不能启动 如何排除故障,开工发现电脑无法开机 如何排查故障?
  2. C#中使用Directory实现对文件夹的常用操作
  3. 一天就能上线音乐教学APP?网易云信首推音乐教学解决方案!
  4. JSON字符串转对象集合
  5. 水系图一般在哪里找得到_水系电池再发Nature,事实力证将迎来发展的春天!
  6. PowerDesigner16.5的下载、安装
  7. 流量卡之家:5G手机价格没那么“邪性” 门槛降低一半
  8. 7个最佳小型企业电子邮件营销服务(2020)
  9. 学生用计算机cf82es,计算器(fx-82ES)玩得好是可以很变态的(必看)(6页)-原创力文档...
  10. 坐标转换 | EXCEL中WGS84转GCJ02,并在地图上标注
  11. Global Illumination_Screen-Space Ray Tracing(SSR)
  12. 《SRE生存指南》金句分享
  13. 用requests和pandas爬取中国福彩网官网 双色球 历年全部彩票数据
  14. 13 路由器RIP动态路由配置
  15. 星起航:如何筛选优质带货达人?
  16. windows删除网络驱动器 - 知乎
  17. 计算机领域cip是什么意思,学术专著的CIP数据是什么意思
  18. 黑马程序员_ios基础总结1_IOS概述
  19. 星座时代:一家企业的自白
  20. Bitmap Png jpg的区别

热门文章

  1. c++-内存管理-array allocator
  2. 解决The current branch is not configured for pull No value for key branch.master.merge found in config
  3. excel转成csv格式的默认分隔符
  4. 非关语言: 设计模式
  5. web框架应具备的功能
  6. centos7编译安装pure-ftpd-1.0.42
  7. iis 7.5应用程序池自动停止
  8. .NET访问PI数据库
  9. Java8 時間API
  10. 面试最后HR都要问一句有没有什么问题要问我?