upstream模块介绍

Nginx的负载均衡功能依赖于ngx_http_upsteam_module模块,所支持的代理方式包括proxy_pass、fastcgi_pass、memcached_pass等,新版Nginx软件支持的方式所以增加。主要针对proxy_pass代理。

ngx_http_upstream_module模块有允许Nginx定义一组或多组服务组,使用的可以通过proxy_pass代理方式吧网站的请求发送到事先定义好的对应upstream组的名字上,具体写法为proxy_pass http://www_server_pools,期中www_server_pools就是一个uupstream节点服务组名字

ngx_http_upsteam_module模块官方地址:

http://nginx.org/en/docs/http/ngx_http_upstream_module.html#upstream

基本的upstream配置案例

#准备环境
cp /application/nginx/conf/nginx.conf{,.bak.before.lb}
cd /application/nginx/conf/ vim /application/nginx/conf/nginx.conf #####web01 web02 web03
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; server {
listen 80;
server_name www.etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
server {
listen 80;
server_name bbs.etiantian.org;
location / {
root html/bbs;
index index.html index.htm;
}
access_log logs/access_bbs.log main;
}
} ###创建环境
mkdir -p /application/nginx/html/{www,bbs}
for dir in www bbs;do echo "`ifconfig eth0|egrep -o "10.0.0.[0-9]+"` $dir" >/application/nginx/html/$dir/bingbing.html;done /application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx -s reload curl 10.0.0.7/bingbing.html
curl 10.0.0.8/bingbing.html
curl 10.0.0.9/bingbing.html ######lb01负载均衡服务器 cd /application/nginx/conf/
cp /application/nginx/conf/nginx.conf{,.bak.before.lb}
cd /application/nginx/conf/ vim /application/nginx/conf/nginx.conf worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65; upstream server_pools {
server 10.0.0.7;
server 10.0.0.8;
server 10.0.0.9;
} server {
listen 80;
server_name www.etiantian.org;
location / {
proxy_pass http://server_pools;
}
}
} /application/nginx/sbin/nginx -t /application/nginx/sbin/nginx -s reload #在lb01测试
curl 10.0.0.5/bingbing.html curl 10.0.0.7/bingbing.html
curl 10.0.0.8/bingbing.html
curl 10.0.0.9/bingbing.html

基本的upstream配置案例

upstream模块介绍的更多相关文章

  1. 基于LNMP(fastcgi协议)环境部署、原理介绍以及fastcgi_cache配置以及upstream模块负载均衡讲解

    ngx_http_proxy_module只能反向代理后端使用HTTP协议的主机.而ngx_http_fastcgi_module只能反向代理后端使用FPM或者使用FastCGI协议的客户端. 一.部 ...

  2. nginx upstream模块--负载均衡

    Module ngx_http_upstream_module英文文档 upstream模块相关说明1.upstream模块应放于nginx.conf配置的http{}标签内2.upstream模块默 ...

  3. nginx upstream模块

    upstream模块 upstream模块 (100%) nginx模块一般被分成三大类:handler.filter和upstream.前面的章节中,读者已经了解了handler.filter. 利 ...

  4. [转帖]nginx upstream模块--负载均衡

    nginx upstream模块--负载均衡 https://www.cnblogs.com/linjiqin/p/5494783.html Module ngx_http_upstream_modu ...

  5. Nginx - upstream 模块及参数测试

    目录 - 1. 前言- 2. 配置示例及指令说明    - 2.1 配置示例    - 2.2 指令    - 2.3 upstream相关变量- 3. 参数配置及测试    - 3.1 max_fa ...

  6. upstream模块实现反向代理的功能

    nginx平台初探(100%) — Nginx开发从入门到精通 http://tengine.taobao.org/book/chapter_02.html#id6 nginx的模块化体系结构¶ ng ...

  7. Nginx核心流程及模块介绍

    Nginx核心流程及模块介绍 1. Nginx简介以及特点 Nginx简介: Nginx (engine x) 是一个高性能的web服务器和反向代理服务器,也是一个IMAP/POP3/SMTP服务器 ...

  8. webkit模块介绍

    一.Webkit模块   用到的第三方库如下:   cairo 一个2D绘图库 casqt Unicode处理用的库,从QT中抽取部分代码形成的 expat 一个XML SAX解析器的库 freety ...

  9. 【液晶模块系列基础视频】1.2.iM_RGB模块介绍

    [液晶模块系列基础视频]1.2.iM_RGB模块介绍(上) [液晶模块系列基础视频]1.2.iM_RGB模块介绍(下) ============================== 技术论坛:http ...

随机推荐

  1. centos找不到环境变量 -bash: ls: command not found

    #在系统中输入命令,报如下错误: [root@a1 work]# ll-bash: ls: command not found #昨时解决办法:export PATH=/usr/local/sbin: ...

  2. redis 简单使用总结

    作者:王清培(Plen wang)  沪江Java资深架构师 最近一段时间与redis接触比较频繁.发现有些东西还是工作中经常会用到的,自己也花了点时间巩固下.本篇文章主要是以总结性的方式梳理,因为r ...

  3. hive-命令操作记录

    Hive 的官方文档请参考:http://wiki.apache.org/hadoop/Hive/LanguageManual . Create Table CREATE [EXTERNAL] TAB ...

  4. 命令 上传项目到git中

    点击Clone or dowload会出现一个地址,copy这个地址备用. 接下来就到本地操作了,首先右键你的项目,如果你之前安装git成功的话,右键会出现两个新选项,分别为Git Gui Here, ...

  5. google map 路线服务

    入门指南 使用 Google Maps JavaScript API 中的路线服务之前,首先要确保在为 Google Maps JavaScript API 设置的同一项目的 Google API C ...

  6. [Python设计模式] 第25章 联合国维护世界和平——中介者模式

    github地址:https://github.com/cheesezh/python_design_patterns 题目背景 联合国在世界上就是中介者的角色,各国之间的关系复杂,类似不同的对象和对 ...

  7. PL/SQL学习笔记之事务

    一:事务自动提交的开启与关闭 1)开启事务自动提交:则每一个INSERT,UPDATE或DELETE命令执行时,都提交一次事务. SET AUTOCOMMIT ON; 2)关闭事务自动提交:则执行到C ...

  8. Linux-进程描述符 task_struct 详解

    为了描述控制进程的运行,系统中存放进程的管理和控制信息的数据结构称为进程控制块 PCB(Process Control Block),它是进程实体的一部分,是操作系统中最重要的记录性数据结构.它是进程 ...

  9. MySQL技术内幕读书笔记(一)——Mysql体系结构和存储引擎

    目录 MySQL体系结构和存储引擎 定义数据库和实例 MYSQL体系结构 MYSQL存储引擎 MySQL体系结构和存储引擎 定义数据库和实例 数据库:物理操作系统文件或者其他形式文件类型的结合.在MY ...

  10. Jmeter执行python脚本函数使用说明

    一.下载地址插件百度网盘下载地址:https://pan.baidu.com/s/1SvJjyThsXYryXuEEg9rm3g提取码:q9hd 二.使用说明1.将下载的jmeter-function ...