1.1 集群是什么

  简单地说,集群就是指一组(若干个)相互独立的计算机,利用高速通信网络组成的一个较大的计算机服务系统,每个集群节点(即集群中的每台计算机)都是运行各自服务的独立服器。这些服务器之间可以彼此通信,协同向用户提供应用程序、系统资源和数据,并以单一系统的模式加以管理。当用户客户机请求集群系统时,集群给用户的感觉就是一个单一独立的服务器,而实际上用户请求的是一组集群服务器。

  打开谷歌、百度的页面,看起来好简单,也许你觉得用几分钟就可以制作出相似的网页,而实际上,这个页面的背后是由成千上万台服务器集群协同工作的结果。而这么多的服务器维护和管理,以及相互协调工作也许就是读者你未来的工作职责了。

  若要用一句话描述集群,即一堆服务器合作做同一件事,这些机器可能需要整个技术团队架构、设计和统一协调管理,这些机器可以分布在一个机房,也可以分布在全国全球各个地区的多个机房。

1.2 为什么要有集群

1.2.1 集群种类

**  负载均衡集群 LB** 解决调度问题

**  高可用集群  HA** 解决单点故障问题(keeplived**)**

  高性能计算集群         HP 、网络计算集群 GC

1.2.2 硬件设备

1.2.3 软件

1.2.4 负载均衡概念说明

  对用户的访问请求进行调度管理

  对用户的访问请求进行压力分担

1.2.5 反向代理

  接收用户请求代替用户向后端访问

  反向代理与数据转发的区别

1.2.6 压力测试的方式

  ab (apache里的命令) 

  通过   yum install httpd-tools   获得

1.3 nginx反向代理实践

1.3.1 地址规划说明

    <td style="width: 174.25pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left: none; background: #a6a6a6; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">IP</span></strong>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left: none; background: #a6a6a6; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">说明</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 174.25pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">lb01</span>
      </p>
    </td>
    
    <td style="width: 174.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.5</span>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">Nginx </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">主负载服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 174.25pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">lb02</span>
      </p>
    </td>
    
    <td style="width: 174.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.6</span>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">辅负载服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 174.25pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web01</span>
      </p>
    </td>
    
    <td style="width: 174.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.8</span>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web01</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 174.25pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web02</span>
      </p>
    </td>
    
    <td style="width: 174.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.7</span>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web02</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 174.25pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web03</span>
      </p>
    </td>
    
    <td style="width: 174.25pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.9</span>
      </p>
    </td>
    
    <td style="width: 174.3pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="232">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">web03</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 522.8pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: windowtext; border-bottom-color: windowtext; border-left-color: windowtext; border-top: none; background: #92d050; padding: 0cm 5.4pt;" colspan="3" width="697">
      <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
        <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">说明:</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">以上为实际生产架构负载实现规划内容</span>
      </p>
    </td>
  </tr>
</table>

1.3.2 反向代理与数据转发的区别

1.3.3 安装部署nginx过程(安装命令集)

1.3.4 编写nginx配置文件(统一web服务器配置)

1.3.5 统一nginx测试环境 (web文件)

1.3.6 测试

1.3.7 配置负载服务文件

1.3.8 测试访问

1.4 nginx中常用模块说明

1.4.1 模块调度算法

1.4.2 nginx反向代理相关两个模块

    upstream 模块 类似与一个池塘,将nginx节点放置到池塘中

    proxy模块  用池塘里面的nginx节点,利用pr oxy进行调用

1.4.3 upstream模块核心参数简介

    weight 权重

    max_fails 抛得次数

    fail_timeout 失败的超时时间

    backup  备份

1.4.4 weight 参数实践 (权重)

  upstream 模块只能在http区块里

测试

1.4.5 其他的参数说明

  max_fails    失败的尝试次数

  fail_timeout 失败后的再次尝试时间

  backup 备份节点:所有的节点都挂掉后数据才会请求web01

测试,将web02停掉

停掉web02后

1.4.6 访问抓包

用户请求报文

负载均衡请求报文

1.4.7 upsrteam参数详细说明

<td style="width: 88.2%; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4472c4; border-right-color: #4472c4; border-bottom-color: #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 1;">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">参数说明</span></strong>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">负载均衡后面的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">RS</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">配置,可以是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">IP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">或域名,如果端口不写,默认是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">80</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">端口。</span>
  </p>
  
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">高并发场景下,</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> IP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">可换成域名,通过</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> DNS</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">做负载均衡。</span>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">代表服务器的权重,默认值是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">1</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">。权重数字越大表示接受的请求比例越大。</span>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">Nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">尝试连接后端主机失败的次数,这个值是配合</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> proxy_next_upstream</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">、</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">fastcgi_next_upstream</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">和</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">memcached_next_upstream </span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这三个参数来使用的。当</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">接收后端服务器返回这三个参数定义的状态码时,会将这个请求转发给正常工作的后端服务器,例如</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">404</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">、</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">502</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">、</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">503</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">、</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> Max_fails</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的默认值是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">1 ; </span>
  </p>
  
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">企业场景下建议</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">2-3</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">次。如京东</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">1</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">次,蓝汛</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">次,根据业务需求去配置</span>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">在</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">max_fails</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">定义的失败次数后,距离下次检查的间隔时间,默认是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10s ;</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">如果</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">max_fails</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">5 ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">它就检测</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">5</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">次,如果</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">5</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">次都是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">502,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">那么,它就会根据</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">fail_timeout</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的值,等待</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10s</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">再去检查,还是只检查一次,如果持续</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">502,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">在不重新加载</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> Nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">配置的情况下,每隔</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10s</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">都只检查一次。常规业务</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">2~3</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">秒比较合理,比如京东</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">3</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">秒,蓝汛</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">3</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">秒,可根据业务需求去配置。</span>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">热备配置(</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">RS</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">节点的高可用),当前面激活的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">RS</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">都失败后会自动启用热备</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">RS</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这标志看这个服务器作为备份服务器,若主服务器全部宕机了,就会向它转发请求。</span>
  </p>
  
  <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">注意:当负载调度算法为</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">ip_hash</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">时,后端服务器在负载均衡调度中的状态不能是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">weight</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">和</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">backup</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">。</span>
  </p>
</td>
<td style="width: 88.2%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="88%">
  <p class="MsoNormal" style="margin-bottom: .0001pt;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这标志着服务器永远不可用,这个参数可配合</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">ip_hash</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">使用;类似与注释。</span>
  </p>
</td>

  weight :调节服务器的请求分配权重。1.4.8 上述命令的说明如下:

    ?check :开启对该服务器健康检查。

    ?inter:设置连续两次的健康检查间隔时间,单位毫秒,默认值2000。

    ?rise :指定多少次连续成功的健康检查后,即可认定该服务器处于可用状态。

    ?fall :指定多少次不成功的健康检查后,即认为服务器为宕机状态,默认值3。

    ? maxconn :指定可被发送到该服务器的最大并发连接数。

1.4.9 ip_hash 参数实践

  每个访问的用户都会生成一个hash值。

      每个请求按客户端 IP的 hash结果分配,当新的请求到达时,先将其客户端 IP通过哈希算法哈希出一个值,在随后的客户端请求中,客户IP的咍希值只要相同,就会被分配至同一台服务器,该调度算法可以解决动态网页的session共享问题,但有时会导致请求分配不均,即无法保证1:1的负载均衡,因为在国内大多数公司都是NAT上网横式,多个客户端会对应_个外部IP ,所以,这些客户端都会被分配到同一节点服务器,从而导致请求分配不均。

          LVS负载均衡的-p参数、Keepalived配置里的 persistence jimeout 50参数都类似这个 Nginx里的ip_hash参数,其功能都可以解决动态网页的session共享问题。

1.4.10 least_conn 参数

  看谁闲,谁闲发送给谁

  least_conn算法会根据后端节点的连接数来决定分配情况,哪个机器连接数少就分发。

1.4.11 fair 参数

  看谁响应的快

  此算法会根据后端节点服务器的响应时间来分配请求,响应时间短的优先分配。这是更加智能的调度算法。此种算法可以依据页面大小和加载时间长短智能地进行负载均衝,也就是根据后端服务器的响应时间来分配请求,响应时间短的优先分配。Nginx本身不支持fair调度算法,如果需要使用这种调度算法,必须下载Nginx的相关模块upstream_fair。

示例如下:

1.4.12 调度算法

  定义轮询调度算法 rr 默认调度算法   平均分配

  定义权重调度算法 wrr

  定义静态调度算法 ip-hash

  定义最小的连接数-least_conn

1.4.13 nginx负载均衡相关重要参数

<td style="width: 75.34%; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left: none; background: #a6a6a6; padding: 0cm 5.4pt;" width="75%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">解释说明</span></strong>
  </p>
</td>
<td style="width: 75.34%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="75%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">通过</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">proxy_pass</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">功能把用户的清求转向到反向代理定义的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">upstream</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器池</span>
  </p>
</td>
<td style="width: 75.34%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="75%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">在代理向后端服务器发送的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> http</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">请求头中加入</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> host</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">字段信息,用于当后端服务器配置有多个虚拟主机时,可以识别代理的是哪个虚拟主机。这是节点服务器多虚拟主机时的关键配置</span>
  </p>
</td>
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">$remote_addr;</span>
  </p>
</td>

<td style="width: 75.34%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="75%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">在代理向后端服务器发送的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> http</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">请求头中加入</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> X-Forward-For</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">字段信息,用于后端服务器程序、日志等接收记录真实用户的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> IP ,</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">而不是代理服务器的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> IP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">这是反向代理时,节点服务器获取用户真实</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> IP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">的必要功能配置</span>
  </p>
</td>

1.4.14 反向代理排错思路

  01.先在lb01上访问后端节点进行测试

  02.在lb01上访问本地地址进行测试

  03.在浏览器上进行测试

          缓存、域名解析

1.4.15 proxy_next_uptream 参数

  当nginx接收后端服务器返回proxy_next_upstream 参数定义的状态码时,会将这个请求转发给正常工作的后端服务器,例如500,502,503,504,此参数可以提升用户的访问体验。

1.5 定义多个虚拟主机标签信息

1.5.1 proxy_set_header 参数

配置文件

}

访问抓包

1.5.2 X-Forwarded-For 参数

  proxy_set_header X-Forwarded-For $remote_addr;

                  代理的啥时候在后面显示真实的IP地址

}

参看日志信息

         该参数配置,会在访问日志的后面加上真正的访问用户ip

1.5.3 http proxy 模块相关参数说明

<td style="width: 79.96%; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: windowtext; border-right-color: windowtext; border-bottom-color: windowtext; border-left: none; background: #a6a6a6; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: center;" align="center">
    <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">&nbsp;</span></strong><strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">说明</span></strong>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">http</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">请求</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">header</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">项传给后端服务器节点,例如:可实现让代理后端的服务器节点获取访问客户端用户的真实</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">IP</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">地址</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">用于指定客户端请求主体缓冲区大小</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示反向代理后端节点服务器连接的超时时间,即发起握手等候响应的超时时间</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">表示代理后端服务器的数据回传时间,即在规定时间内后端服务器必须传完所有数据,否则</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">将断开这个连接</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">从代理的后端服务器获取信息的时间,表示连接建立成功后,</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">等待后端服务器的响应时间,其实是</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">已经进入后端的排队之中等候处理的时间</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" valign="top" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置缓冲区大小,默认该缓冲区大小等于指令</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">proxy_buffers</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置的大小</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">设置缓冲区的数量和大小,</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">nginx</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">从代理的后端服务器获取的响应信息,会设置到缓冲区</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">用于设置相同很忙时可以使用的</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">proxy_buffers</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">大小,官方推荐的大小为</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US"> proxy_buffers * 2</span>
  </p>
</td>
<td style="width: 79.96%; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: windowtext; border-right-width: 1pt; border-right-color: windowtext; padding: 0cm 5.4pt;" width="79%">
  <p class="MsoNormal" style="margin-bottom: .0001pt; text-align: justify; text-justify: inter-ideograph;">
    <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">指定</span><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">proxy</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">缓存临时文件的大小</span>
  </p>
</td>

1.6.1 相据URL目录地址转发的应用场景1.6 基于目录(uri)进行转发–网站动静分离

  根据HTTP的URL进行转发的应用情况,被称为第7层(应用层)的负载均衡,而LVS的负载均衡一般用于TCP等的转发,因此被称为第4层(传输层)的负载均衡。

  在企业中,有时希望只用一个域名对外提供服务,不希望使用多个域名对应同一个产品业务,此时就需要在代理服务器上通过配置规则,使得匹配不同规则的请求会交给不同的服务器池处理。这类业务有:

  ? 业务的域名没有拆分或者不希望拆分,但希望实现动静分离、多业务分离,

  ? 不同的客户端设备(例如:手机和 PC端)使用同一个域名访问同一个业务网站,就需要根 据规则将不同设备的用户请求交给后端不同的服务器处理,以便得到最佳用户体验。

1.6.2 第一个里程碑: 服务器规划

    <td style="width: 130.45pt; border-top-width: 1pt; border-top-color: #4472c4; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4472c4; border-right: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="174">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 1;">
        <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体; color: white; mso-themecolor: background1;" lang="EN-US">ip</span></strong>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top-width: 1pt; border-top-color: #4472c4; border-left: none; border-bottom-width: 1pt; border-bottom-color: #4472c4; border-right: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 1;">
        <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">服务器目录</span></strong>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top-width: 1pt; border-right-width: 1pt; border-bottom-width: 1pt; border-top-color: #4472c4; border-right-color: #4472c4; border-bottom-color: #4472c4; border-left: none; background: #4472c4; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 1;">
        <strong><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman'; color: white; mso-themecolor: background1;">类型</span></strong>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 139.65pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #8eaadb; border-bottom-color: #8eaadb; border-left-color: #8eaadb; border-top: none; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="186">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 68;">
        <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">/upload</span></strong>
      </p>
    </td>
    
    <td style="width: 130.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="174">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.8:80</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">html/www/upload</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">upload</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 139.65pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #8eaadb; border-bottom-color: #8eaadb; border-left-color: #8eaadb; border-top: none; padding: 0cm 5.4pt;" valign="top" width="186">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 4;">
        <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">/static</span></strong>
      </p>
    </td>
    
    <td style="width: 130.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="174">
      <p class="MsoNormal" style="margin-bottom: .0001pt;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.7:80</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">html/www/static</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">static</span><span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">静态服务器</span>
      </p>
    </td>
  </tr>
  
  <tr>
    <td style="width: 139.65pt; border-right-width: 1pt; border-bottom-width: 1pt; border-left-width: 1pt; border-right-color: #8eaadb; border-bottom-color: #8eaadb; border-left-color: #8eaadb; border-top: none; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="186">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 68;">
        <strong><span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">/</span></strong>
      </p>
    </td>
    
    <td style="width: 130.45pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="174">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">10.0.0.9:80</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 'Times New Roman',serif; mso-fareast-font-family: 宋体;" lang="EN-US">html/www</span>
      </p>
    </td>
    
    <td style="width: 126.35pt; border-top: none; border-left: none; border-bottom-width: 1pt; border-bottom-color: #8eaadb; border-right-width: 1pt; border-right-color: #8eaadb; background: #d9e2f3; padding: 0cm 5.4pt;" valign="top" width="168">
      <p class="MsoNormal" style="margin-bottom: .0001pt; mso-yfti-cnfc: 64;">
        <span style="font-size: 10.0pt; font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';">默认</span>
      </p>
    </td>
  </tr>
</table>

1.6.3 第二个里程碑:创建/设置upstream负载信息

1.6.4 第三个里程碑:如何调用upstream信息

1.6.5 第四个里程碑: 编写配置文件lb01

upstream static_pools {
  server </span><span style="color: #800080;">10.0</span>.<span style="color: #800080;">0.7</span>:<span style="color: #800080;">80</span><span style="color: #000000;">;
}

upstream default_pools {
  server </span><span style="color: #800080;">10.0</span>.<span style="color: #800080;">0.9</span>:<span style="color: #800080;">80</span><span style="color: #000000;">;
}

server {
    listen </span><span style="color: #800080;">80</span><span style="color: #000000;">;
    server_name www.etiantian.org;
location </span>/static/<span style="color: #000000;"> { 
    proxy_pass http:</span><span style="color: #008000;">//</span><span style="color: #008000;">static_pools;</span>

proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; }

    location </span>/upload/<span style="color: #000000;"> { 
        proxy_pass http:</span><span style="color: #008000;">//</span><span style="color: #008000;">upload_pools;</span>

proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; }

 location </span>/<span style="color: #000000;"> { 
        proxy_pass http:</span><span style="color: #008000;">//</span><span style="color: #008000;">default_pools;</span>

proxy_set_header Host $host; proxy_set_header X-Forwarded-For $remote_addr; } access_log logs/access_www.log main; } }

1.6.6 第五个里程碑: 创建环境

##web01

##web02

##web03

1.6.7 第六个里程碑: 进行测试

浏览器进行访问测试

1.7 根据客户端的设备实现转发(user_agent)

1.7.1 user_agent的应用

1.7.2 修改lb01配置文件 

<div id="cnblogs_code_open_a5fab604-162f-4ee1-b327-47a219d21cc2" class="cnblogs_code_hide">
  <pre><span style="color: #008080;"> 1</span> worker_processes  <span style="color: #800080;">1</span><span style="color: #000000;">;

2 events { 3 worker_connections 1024; 4 } 5 http { 6 include mime.types; 7 default_type application/octet-stream; 8 sendfile on; 9 keepalive_timeout 65; 10 log_format main $remote_addr - $remote_user [$time_local] “$request” 11 $status $body_bytes_sent “$http_referer” 12 "$http_user_agent" “$http_x_forwarded_for”; 13
14 upstream upload_pools { 15 server 10.0.0.8:80; 16 } 17 18 upstream static_pools { 19 server 10.0.0.7:80; 20 } 21 22 upstream default_pools { 23 server 10.0.0.9:80; 24 } 25 26 server { 27 listen 80; 28 server_name www.etiantian.org; 29 location / { 30 if ($http_user_agent ~* "MSIE") 31 { 32 proxy_pass http://static_pools; 33 } 34 if ($http_user_agent ~* "Chrome") 35 { 36 proxy_pass http://upload_pools; 37 } 38 proxy_pass http://default_pools; 39 proxy_set_header Host $host; 40 } 41 access_log logs/access_www.log main; 42 } 43 }

<p>
  <span class="cnblogs_code_collapse">View Code lb01配置文件</span></div> </div> 
  
  <h3>
    <span id="173">1.7.3 进行测试</span>
  </h3>
  
  <div>
    <p class="a">
        基于上一步的操作,现在可以之间的进行访问测试
    </p>
  </div>
  
  <p>
    curl -A 指定访问类型
  </p>
  
  <div>
    <div class="cnblogs_code">
      <pre>[root@lb01 conf]# curl -A MSIE -H host:www.etiantian.org <span style="color: #800080;">10.0</span>.<span style="color: #800080;">0.5</span><span style="color: #000000;">

web02 www [root@lb01 conf]# curl -A Chrome -H host:www.etiantian.org 10.0.0.5 web01 www [root@lb01 conf]# curl -A xx -H host:www.etiantian.org 10.0.0.5 web03 www

  <h2>
    <span id="18">1.8 利用扩展名进行转发</span>
  </h2>
  
  <p>
    利用后缀名进行转发与nginx中的基于后缀的转跳一样实现。
  </p>
  
  <div>
    <div class="cnblogs_code">
      <pre>location ~.*.(gif|ipg|jpeg|png|bmp|swf|css|<span style="color: #000000;">js)$ {
    peoxy_pass http:</span><span style="color: #008000;">//</span><span style="color: #008000;">static_pools;</span>

include proxy.conf }

    <p style="text-align: right;">
      &nbsp;<strong>本文出自&ldquo;惨绿少年&rdquo;,欢迎转载,转载请注明出处!http://blog.znix.top</strong>
    </p>
  </div>
  
  <p>
    &nbsp;
  </p>
  
  <div id="toc_container" class="toc_white have_bullets">
    <ul class="toc_list">
      <li>
        <a href="#11">1.1 集群是什么</a>
      </li>
      <li>
        <a href="#12">1.2 为什么要有集群</a><ul>
          <li>
            <a href="#121">1.2.1 集群种类</a>
          </li>
          <li>
            <a href="#122">1.2.2 硬件设备</a>
          </li>
          <li>
            <a href="#123">1.2.3 软件</a>
          </li>
          <li>
            <a href="#124">1.2.4 负载均衡概念说明</a>
          </li>
          <li>
            <a href="#125">1.2.5 反向代理</a>
          </li>
          <li>
            <a href="#126">1.2.6 压力测试的方式</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#13_nginx">1.3 nginx反向代理实践</a><ul>
          <li>
            <a href="#131">1.3.1 地址规划说明</a>
          </li>
          <li>
            <a href="#132">1.3.2 反向代理与数据转发的区别</a>
          </li>
          <li>
            <a href="#133_nginx">1.3.3 安装部署nginx过程(安装命令集)</a>
          </li>
          <li>
            <a href="#134_nginxweb">1.3.4 编写nginx配置文件(统一web服务器配置)</a>
          </li>
          <li>
            <a href="#135_nginx_web">1.3.5 统一nginx测试环境 (web文件)</a>
          </li>
          <li>
            <a href="#136">1.3.6 测试</a>
          </li>
          <li>
            <a href="#137">1.3.7 配置负载服务文件</a>
          </li>
          <li>
            <a href="#138">1.3.8 测试访问</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#14_nginx">1.4 nginx中常用模块说明</a><ul>
          <li>
            <a href="#141">1.4.1 模块调度算法</a>
          </li>
          <li>
            <a href="#142_nginx">1.4.2 nginx反向代理相关两个模块</a>
          </li>
          <li>
            <a href="#143_upstream">1.4.3 upstream模块核心参数简介</a>
          </li>
          <li>
            <a href="#144_weight">1.4.4 weight 参数实践 (权重)</a>
          </li>
          <li>
            <a href="#145">1.4.5 其他的参数说明</a>
          </li>
          <li>
            <a href="#146">1.4.6 访问抓包</a>
          </li>
          <li>
            <a href="#147_upsrteam">1.4.7 upsrteam参数详细说明</a>
          </li>
          <li>
            <a href="#weight_148">  weight :调节服务器的请求分配权重。1.4.8 上述命令的说明如下:</a>
          </li>
          <li>
            <a href="#149_ip_hash">1.4.9 ip_hash 参数实践</a>
          </li>
          <li>
            <a href="#1410_least_conn">1.4.10 least_conn 参数</a>
          </li>
          <li>
            <a href="#1411_fair">1.4.11 fair 参数</a>
          </li>
          <li>
            <a href="#1412">1.4.12 调度算法</a>
          </li>
          <li>
            <a href="#1413_nginx">1.4.13 nginx负载均衡相关重要参数</a>
          </li>
          <li>
            <a href="#1414">1.4.14 反向代理排错思路</a>
          </li>
          <li>
            <a href="#1415_proxy_next_uptream">1.4.15 proxy_next_uptream 参数</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#15">1.5 定义多个虚拟主机标签信息</a><ul>
          <li>
            <a href="#151_proxy_set_header">1.5.1 proxy_set_header 参数</a>
          </li>
          <li>
            <a href="#152_X-Forwarded-For">1.5.2 X-Forwarded-For 参数</a>
          </li>
          <li>
            <a href="#153_http_proxy">1.5.3 http proxy 模块相关参数说明</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#161_URL16_uri">1.6.1 相据URL目录地址转发的应用场景1.6 基于目录(uri)进行转发--网站动静分离</a><ul>
          <li>
            <a href="#162">1.6.2 第一个里程碑: 服务器规划</a>
          </li>
          <li>
            <a href="#163_upstream">1.6.3 第二个里程碑:创建/设置upstream负载信息</a>
          </li>
          <li>
            <a href="#164_upstream">1.6.4 第三个里程碑:如何调用upstream信息</a>
          </li>
          <li>
            <a href="#165_lb01">1.6.5 第四个里程碑: 编写配置文件lb01</a>
          </li>
          <li>
            <a href="#166">1.6.6 第五个里程碑: 创建环境</a>
          </li>
          <li>
            <a href="#167">1.6.7 第六个里程碑: 进行测试</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#17_user_agent">1.7 根据客户端的设备实现转发(user_agent)</a><ul>
          <li>
            <a href="#171_user_agent">1.7.1 user_agent的应用</a>
          </li>
          <li>
            <a href="#172_lb01nbsp">1.7.2 修改lb01配置文件&nbsp;</a>
          </li>
          <li>
            <a href="#173">1.7.3 进行测试</a>
          </li>
        </ul>
      </li>
      
      <li>
        <a href="#18">1.8 利用扩展名进行转发</a>
      </li>
    </ul>
  </div>