编译nginx增加fair模块

安装必要的软件

ubuntu里是

apt install wget gcc make zlib1g-dev libpcre3-dev

 

去官网下载最新稳定版的nginx源码

 

git clone 源码

git clone 'https://github.com/gnosek/nginx-upstream-fair.git'

根据提示修改源码的BUG

https://github.com/gnosek/nginx-upstream-fair/pull/27/commits/ff979a48a0ccb9217437021b5eb9378448c2bd9e

开始编译

./configure --prefix=/root/go/nginx --add-module=/root/nginx-upstream-fair

 

最后做下链接

rm -rf /usr/sbin/nginx
ln -s /root/go/nginx/sbin/nginx /usr/sbin/nginx

 

 

 

最后贴一个我在用的nginx.conf

user nginx;
worker_processes auto;
worker_rlimit_nofile 30000;

events {
    worker_connections 10240;
}

http {
    upstream http8080 {
        server 192.168.100.1:8080;
        server 192.168.100.2:8080;
        fair;
    }
    server {
        listen 127.0.0.1:8080;
        location / {
            proxy_pass http://http8080;
        }
    }
}

 

posted on 2020-12-23 06:53  项希盛  阅读(293)  评论(0编辑  收藏  举报