编译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

 

最后贴一个我在用的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;
        }
    }
}

 

上一篇:公司服务器中了.fair勒索病毒,该如何正确应对?


下一篇:Nginx负载均衡策略