安装nginx进行Qos,限制下载和上传速度

1.安装

所需软件链接: https://pan.baidu.com/s/1zduhpxfuETxW3R_ZZ1sR_g 提取码: ybka
安装的操作系统是Centos7.9

yum -y install gcc gcc-c++  bison libgcrypt perl make cmake openssl-devel openssl

tar -xzvf nginx-1.4.7.tar.gz

unzip limit_upload_rate-master.zip
mv limit_upload_rate-master nginx-1.4.7/

unzip Nginx-limit-traffic-rate-module-master.zip
mv Nginx-limit-traffic-rate-module-master nginx-1.4.7/

cd nginx-1.4.7
patch -p1 < limit_upload_rate-master/for-nginx-1.4.4.patch

#开始加入模块编译安装
./configure  --prefix=/app/soft/nginxlimit --conf-path=/app/soft/nginxlimit/conf/nginx.conf --user=nginx --group=nginx --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock  --http-client-body-temp-path=/tmp/ --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --with-http_ssl_module --with-select_module --with-poll_module --with-file-aio  --add-module=limit_upload_rate-master --add-module=Nginx-limit-traffic-rate-module-master

make ; make install

在这里插入图片描述在这里插入图片描述

2.配置

在nginxi的配置location块加入如下配置

  location / {
                limit_conn addr 100;
                limit_rate 5k;
                limit_rate_after 200k;
                limit_upload_rate 100k;

limit_conn addr 是每个ip最多能建立多少个连接,上面的例子是100个连接
limit_rate 是下载限速,上面限速是5k
limit_rate_after 是在下载多少后,开始限速,上面是现在200k后开始限速
limit_upload_rate 是上传限速,上面的例子是100k上传速度

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

机核动力

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值