点赞
评论
收藏
分享
举报
nginx-upstream-fair
发表于2023-03-23 18:46

浏览 511

文章标签

upstream-fair模块
upstream-fair是比内建的负载均衡更加智能的负载均衡模块,一般google关键词nginx-upstream-fair可以找到相关资源和文章,这里不详述了。它采用的不是内建负载均衡使用的轮换的均衡算法,而是可以根据页面大小、加载时间长短智能的进行负载均衡。
可以通过github获取,地址是https://github.com/gnosek/nginx-upstream-fair
googlecode上也有http://wcoserver.googlecode.com/files/gnosek-nginx-upstream-fair-2131c73.tar.gz
注意:这个版本可能已经过时,推荐使用github上的master zip包
获取到nginx-upstream-fair-master.zip或者gnosek-nginx-upstream-fair-2131c73.tar.gz后解压缩
unzip nginx-upstream-fair-master.ziptar zxvf gnosek-nginx-upstream-fair-2131c73.tar.gz
为了方便起见,把加压缩后得到文件夹更改一下名字,比如upstream
mv nginx-upstream-fair-master upstreammv gnosek-nginx-upstream-fair-2131c73 upstream
如果你喜欢用rename也行,具体可以自己操作。

编译安装nginx
接下来进入解压缩之后的目录
cd nginx-1.2.7/
配置参数
./configure --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/home/uname/upstream/
注意最后一个参数–add-module=/home/uname/upstream/的路径,之前假定的工作目录为/home/uname(uname为你的用户根目录),我们下载的gnosek-nginx-upstream-fair压缩包在这里解压并且更名未upstream,此处填写绝对路径。
配置结束应该不会报错,我在ubuntu12.04和debian6上都做过安装,并且作为开发和生产环境一直在运行,如果有问题可以联系我。
接下来编译安装
sudo makesudo make install
等待编译结束,安装完成
执行文件被安装在/etc/nginx/sbin/nginx,如果你想安装到/usr下可以更改前面的配置参数,这里可以这样在/usr/sbin中建立软链接
cd /usr/sbinsudo ln -s /etc/nginx/sbin/nginx
然后你在任意位置执行
nginx -v
应该能看到nginx版本信息
nginx version: nginx/1.2.7
查看详细配置信息
nginx -V
显示详细信息
nginx version: nginx/1.2.7built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5)TLS SNI support enabledconfigure arguments: --prefix=/etc/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --lock-path=/var/lock/nginx.lock --pid-path=/var/run/nginx.pid --with-debug --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-ipv6 --with-mail --with-mail_ssl_module --add-module=/home/uname/upstream/

附一个nginx使用upstream-fair的配置文件示例:

upstream your-site {server 127.0.0.1:5550;server 127.0.0.1:5551;fair;}server {listen 80;server_name yoursite.com www.yoursite.com;access_log /var/log/nginx/access.log;location / {proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header X-Forwarded-Proto $scheme;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 60s;proxy_send_timeout 90s;proxy_read_timeout 90s;proxy_buffering off;proxy_temp_file_write_size 64k;proxy_pass http://your-site;proxy_redirect off;}}
已修改于2023-03-23 18:46
本作品系原创
创作不易,留下一份鼓励
BUG退散

暂无个人介绍

关注



写下您的评论
发表评论
全部评论(0)

按点赞数排序

按时间排序

关于作者
BUG退散
这家伙很懒还未留下介绍~
11
文章
2
问答
0
粉丝
相关文章
介绍nginx网页配置工具QQ技术交流群1:1106758598QQ技术交流群2:560797506邮箱: cym1102@qq.com官网地址: http://www.nginxwebui.cn码云: https://gitee.com/cym1102/nginxWebUIgithub: https://github.com/cym1102/nginxWebUI功能特点nginxWebUI也可管理多个nginx服务器集群,随时一键切换到对应服务器上进行nginx配置,也可以一键将某台服务器配置同步到其他服务器,方便集群管理.部署此项目后,配置nginx再也不用上网各种搜索配置代码,再也不用手动申请和配置ssl证书,只需要在本项目中进行增删改查就可方便的配置和启动nginx。技术说明本项目是基于springBoot的web系统,数据库使用sqlite,因此服务器上不需要安装任何数据库项目启动时会释放一个.sqlite.db到系统用户文件夹中,注意进行备份本系统通过Let'sencrypt申请证书,使用acme.sh脚本
点赞 6
浏览 6.4k
  前三周学习了陶辉老师的“NGINX基础培训系列课程”,感觉受益良多,在这里想把一些知识点记录一下,和大家分享一下知识点,也方便日后的随手查看,温故知新。  首先,我们了解到了Nginx的版本,Nginx发布版本分为主线版本和稳定版本,区分两个版本也非常简单,主线版本版本号为单数,比如1.19,稳定版本为双数,比如1.18,今天我要说的是稳定版本,这个版本会尽量少的减少Nginx的bug问题,适用于生产环境,这里我不建议使用Nginx和其他软件一样在生产环境中落后一个或多个大版本使用,之前生产环境做过漏扫,发现我们编译自带的Nginx版本为:nginx/1.13.3(查询命令为nginx-V),结果出现了多个漏洞,四个高危和一个中危漏洞:        通过升级Nginx到稳定版最新版本后修复!  其次,是Nginx发行版本的选择,目前比较流行的有:nginx、nginxplus、Tengine、openresty、ope
点赞 1
浏览 3.5k
感谢您参加“NGINX从入门到精通进阶系列培训”!以下为培训的问答、课件和录像,希望您能通过此培训学有所得,祝学习进步!>问与答:- 基础篇+高级篇 - 应用篇+实战篇(New)>课件(PPT):基础篇:-NGINX概要、安装、配置:https://interact.f5.com/rs/653-SMC-783/images/CNFEB22-NginxCoreCourse-Setup.pdf-NGINX日志、运维:https://interact.f5.com/rs/653-SMC-783/images/cnfeb22-nginxcorecourse-maintenance.pdf高级篇:-NGINX变量、API:https://interact.f5.com/rs/653-SMC-783/images/CNFEB22-NginxCoreCourse-API.pdf-NGINXSSL、NJS:https://interact.f5.com/rs/653-SMC-783/images/CNFEB22-NginxCoreCourse-SSL.pdf
点赞 10
浏览 5k