zoukankan      html  css  js  c++  java
  • nginx负载均衡(3)

    1、概述

       增加服务器的数量,然后将请求分发到各个服务器上,将原先请求集中到单个服务器上的请求改为将请求分发到多个服务器上,将负载分发到不同的服务器,也就是我们所属的负载均衡。

    2、nginx 配置实例:负载均衡

    2.1、实现效果

    (1)浏览器输入 http: //192.168.92.128/edu/a.html,负载均衡效果,平均到 8080 和 8081 中去。

    2.2、准备工作

    (1)准备两天 tomcat 服务器, 一台是8080,一台是8081;
    (2)在两台 tomcat 的 webapps 下,创建名为 edu 的文件夹,在里面添加一个页面,用于测试;

    2.3、 nginx 中配置

     在 nginx 的配置文件中配置如下:
     在 http 中配置:

     34     #负载均衡服务列表配置
     35     upstream myserver{
     36         server  192.168.92.128:8080;
     37         server  192.168.92.128:8081;
     38     }
    
    

    在 server 中配置:

     40     server {
     41         listen       80;
     42         server_name  192.168.92.128;
     43
     44         location / {
     45             proxy_pass  http://myserver;
     46             root   html;
     47             index  index.html index.htm;
     48         }
     49 
    

     

  • 相关阅读:
    Elastic 技术栈之快速入门
    JDK8 指南(译)
    Intellij IDEA 使用小结
    面向对象1
    函数总结
    Python中i = i + 1与i + = 1的区别
    python中变量的交换
    python的数据类型的有序无序
    对列表里的字典按年龄从小到大排序
    centos7安装python3
  • 原文地址:https://www.cnblogs.com/hwllovelq/p/12132452.html
Copyright © 2011-2022 走看看