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. hdu5299 Circles Game

    Circles Game Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Tot ...

  2. js-工具函数

    /** * 将文件大小转换成 ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'],单位 * @param bytes * @returns */ ...

  3. let's encrypt申请

    let's encrypt申请 https://keelii.com/2016/06/12/free-https-cert-lets-encrypt-apply-install/ https://ww ...

  4. 通过Comparable来实现对自身的比较

    import org.apache.commons.lang.builder.CompareToBuilder; import org.apache.commons.lang.builder.Equa ...

  5. Java之JavaWeb项目开发开始准备

    操作系统:Mac OS 10.11.6 Tomcat版本:9.0.0.M17 前言:部署Tomcat可以参考我一年前做的笔记:<在MAC下搭建JSP开发环境>,也可以参考大神写的挺好的&l ...

  6. Atitit 支出分类表 会计科目(1)资产(2)负债(3)资本(4)收益(5)费用(成本) 资产分类表 attilax总结

    Atitit 支出分类表  会计科目(1)资产(2)负债(3)资本(4)收益(5)费用(成本)  资产分类表 attilax总结 会计科目对一般不懂会计的管理人员,常会有莫测高深的感觉,因此不仅不愿去 ...

  7. GCC:/usr/lib/libstdc++.so.6: version GLIBCXX_3.4.15 not found

    源码编译升级安装了gcc后,编译程序或运行其它程序时,有时会出现类似/usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.15' not found的问题.这 ...

  8. ios调试-查看日志

    连上mac,然后打开“console.app”, 左侧设备里选这个设备.

  9. Docker容器启动lnmp环境下的mysql服务时报"MySQL server PID file could not be found"错误解决办法

    我在自己的mac笔记本上装了一个docker,并在docker容器中安装了lnmp环境,经常会遇到在使用"lnmp restart"命令启动lnmp服务的时候,mysql服务启动失 ...

  10. 【转】pymongo实现模糊查询

    pymongo 模糊匹配查询在mongo中这样实现 {'asr':/若琪/} 使用pymongo 两种实现方式 1.import re {'asr':re.compile('若琪')} 2.{'asr ...