Nginx Upstream模块

简介:

品茶:这是与大神JSBBA一块交流而录的视频,结果视频出问题了,不能正常,所以无法播放。看到老版后进入了新版页面,结果全是商业版的功能,不过有些东西理解好了


#nginx upstream

我是品茶 还有大神JSBBA 一起交流

负载均衡

硬件-F5

开源-{

lvs+keepalived

haproxy

nginx

}

nginx upstream


ups {

web1

web2

web3  标注为不可用

}

upstreamModule:

优点:iphash hash(remote_addr)

nginx hashmap{

"7675334710322792576":"web1"

}

1、

client1(100.2) > nginx -hash(remmote_addr) > web1

2、

client1(100.2) > nginx -hash(remmote_addr) > web1

3、

client2(200.3) > nginx -hash(remmote_addr) > web2

反向代理:

client >> 反向代理{

web1

web2

web3

} >>server


反向代理 接近服务器的

正向代理 接近客户端的也就是自己的

透明代理 客户端完全不知道有代理这个东西


proxy_pass ups;



upstream backend {

   server backend1.example.com       weight=5;

   server backend2.example.com:8080;

   server unix:/tmp/backend3;


   server backup1.example.com:8080   backup;

   server backup2.example.com:8080   backup;

}


http{

server{

localtion{

image_fillter_module

proxy_pass

}

}

}

server {

   location / {

       proxy_pass http://backend;

   }

}

说明:

syntax:upstream name { ... }

default: —

context:http


syntax:server address [parameters];

default: —

context:upstream

server parameters {

weight=number 1

masx_fails=number 1

fail_timeout=time 10

slow_start=time 0(商业版本才有的功能)

backup 备机

down 停用  (ip_hash)

route=string

}


syntax:match name { ... }

default: —

context:http



syntax:zone name size;

default: —

context:upstream

间隔 5   连续失败 1连续通过 1 url  /   检测状态

syntax:health_check [interval=time] [fails=number] [passes=number] [uri=uri] [match=name];

default: —

context:location


syntax:keepalive connections;

default: —

context:upstream

This directive appeared in version 1.1.4.




upstream appservers {

   zone appservers 64k;


   server appserv1.example.com      weight=5;

   server appserv2.example.com:8080 fail_timeout=5s slow_start=30s;

   server 192.0.2.1                 max_fails=3;


   server reserve1.example.com:8080 backup;

   server reserve2.example.com:8080 backup;

}


server {

   location / {

       proxy_pass http://appservers;

       health_check;

   }


   location /upstream_conf {

       upstream_conf;

       allow 127.0.0.1;

       deny all;

   }

}


check www.baidu.com 80

if status == "200"

   open 127.0.0.1/upstream_conf?upstream=ups&server=appserv1.example.com&weight=8

pass


NB:

http://127.0.0.1/upstream_conf?add=&upstream=appservers&server=127.0.0.1:8080&weight=2&max_fails=3&fail_timeout=3s&down=


任务:

upstream池两个,通过upstream_conf添加一个








check /

down


check /bbs

check /blog



location /bbs {

proxy_pass http://192.168.100.102;

}


location /blog {

proxy_pass http://192.168.100.103;

}

health_check   uri="/bbs" match=200


http://www.a.com/ ok

http://www.a.com/bbs not ok


keepalied 500 501连接的时候,

pool{

501

2

3

4}





本文转自 煮酒品茶 51CTO博客,原文链接:http://blog.51cto.com/cwtea/1343371,如需转载请自行联系原作者
目录
相关文章
|
应用服务中间件 nginx
Nginx安装nginx-rtmp-module模块
【2月更文挑战第4天】 nginx中的模块虽然就是类似插件的概念,但是它无法像VsCode那样轻松的安装扩展。 nginx要安装其它模块必须同时拿到nginx源代码和模块源代码,然后手动编译,将模块打到nginx中,最终生成一个名为nginx的可执行文件。
1129 6
|
应用服务中间件 nginx
百度搜索:蓝易云【利用nginx内置ngx_http_mirror_module模块实现流量复制及流量放大】
以上就是使用Nginx内置 `ngx_http_mirror_module`模块实现流量复制和流量放大的简要示例。通过合理配置和利用该模块,可以实现更复杂的流量控制和调试需求。
480 1
|
网络协议 应用服务中间件 nginx
解决 nginx 启动错误host not found in upstream "XXXX.com“
在前置机上利用nginx进行反向代理的时候,我们会配置proxy_pass。在启动nginx的会报如下错误:host not found in upstream "XXXX.com“
7282 0
|
负载均衡 应用服务中间件 API
Nginx:location配置模块的用法(一)
Nginx:location配置模块的用法(一)
1766 2
|
缓存 应用服务中间件 nginx
安装nginx-http-flv-module模块
本文介绍如何为Nginx安装`nginx-http-flv-module`模块。此模块基于`nginx-rtmp-module`二次开发,不仅具备原模块的所有功能,还支持HTTP-FLV播放、GOP缓存、虚拟主机等功能。安装步骤包括:确认Nginx版本、下载相应版本的Nginx与模块源码、重新编译Nginx并加入新模块、验证模块安装成功。特别注意,此模块已包含`nginx-rtmp-module`功能,无需重复编译安装。
1407 3
|
负载均衡 应用服务中间件 Linux
在Linux中,常用的 Nginx 模块有哪些,常来做什么?
在Linux中,常用的 Nginx 模块有哪些,常来做什么?
|
缓存 前端开发 应用服务中间件
Nginx:location配置模块的用法(二)
Nginx:location配置模块的用法(二)
1371 2
|
应用服务中间件 nginx C++
nginx的cgi模块
nginx的cgi模块
260 0
|
负载均衡 应用服务中间件 nginx
解决nginx配置负载均衡时invalid host in upstream报错
在Windows环境下,配置Nginx 1.11.5进行负载均衡时遇到问题,服务无法启动。错误日志显示“invalid host in upstream”。检查发现上游服务器列表中,192.168.29.128的主机地址无效。负载均衡配置中,两个服务器地址前误加了"http://"。修正方法是删除上游服务器列表和proxy_pass中的"http://"。问题解决后,Nginx服务应能正常启动。
1146 4
解决nginx配置负载均衡时invalid host in upstream报错
|
应用服务中间件 Linux nginx
FFmpeg开发笔记(四十)Nginx集成rtmp模块实现RTMP推拉流
《FFmpeg开发实战》书中介绍了如何使用FFmpeg向网络推流,简单流媒体服务器MediaMTX不适用于复杂业务。nginx-rtmp是Nginx的RTMP模块,提供基本流媒体服务。要在Linux上集成rtmp,需从官方下载nginx和nginx-rtmp-module源码,解压后在nginx目录配置并添加rtmp模块,编译安装。配置nginx.conf启用RTMP服务,监听1935端口。使用ffmpeg推流测试,如能通过VLC播放,表明nginx-rtmp运行正常。更多详情见书本。
697 0
FFmpeg开发笔记(四十)Nginx集成rtmp模块实现RTMP推拉流