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. iOS 获取IP

    #import <ifaddrs.h> //获取IP #import <arpa/inet.h> //只能获取WIFI下的IP地址 + (NSString *)getIPAdd ...

  2. 【PHP】解析PHP中的变量

    php是一门脚本语言,同时php中的变量类型也是弱语言类型,这和javascript非常相似.笔者在这里说一说PHP中的变量知识点. 1. 引用类型变量 看下面的案例: <?php class ...

  3. Django Http请求生命周期

    day54 请求响应Http 1.发送Http请求 2.服务器接收,根据请求头中的的url在路由关系表中进行匹配(从上到下) 3.匹配成功后,执行指定的views函数 4.业务处理 URL----&g ...

  4. 10个基本的HTML5动画工具设计

    HTML5已经成为最流行的编程语言在web开发者.强大的编程语言有很大的能力,生产更好的万维网内容.HTML5的兴起已经在过去三年增长迅速.介绍了HTML5的新技术是更好的.HTML5技术是由像Chr ...

  5. Jupyter/JupyterLab安装使用

    一.介绍 Jupyther notebook(曾经的Ipython notebook),是一个可以把代码.图像.注释.公式和作图集于一处,实现可读性及可视化分析的工具,支持多种编程语言.官方使用手册. ...

  6. mysql主从复制延迟问题的相关知识与解决方案

    一.如何监控发生了主从延迟? 在从库机器上,执行show slave status,查看Seconds_Behind_Master值,代表主从同步从库落后主库的时间,单位为秒,若同从同步无延迟,这个值 ...

  7. Java编程的逻辑 (92) - 函数式数据处理 (上)

    本系列文章经补充和完善,已修订整理成书<Java编程的逻辑>,由机械工业出版社华章分社出版,于2018年1月上市热销,读者好评如潮!各大网店和书店有售,欢迎购买,京东自营链接:http:/ ...

  8. php -- 断点调试 之 选择合适的xdebug

    这里不讲如何在不同的ide里安装断点调试,讲一个不起眼却很容易犯的错误: 如何寻找适合你的环境的xdebug! 不要小看这个问题,如果说xdebug都错了,你再怎么安装断点调试,都不会成功,反而还找不 ...

  9. C# 在while循环中new的对象

    一: 问:那每次循环都会new一个A?那内存不是会满吗?还是说要把这个初始化对象的动作放到循环外面的写法会比较好? while(true) { A a = new A(); ... sleep(100 ...

  10. SpringBoot面试题及答案整理

    1. Spring 和 SpringBoot 有什么不同? Spring 框架提供多种特性使得 web 应用开发变得更简便,包括依赖注入.数据绑定.切面编程.数据存取等等. 随着时间推移,Spring ...