Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

没有限制住速度 #5

Open
theburn opened this issue Jul 27, 2016 · 3 comments
Open

没有限制住速度 #5

theburn opened this issue Jul 27, 2016 · 3 comments

Comments

@theburn
Copy link

theburn commented Jul 27, 2016

  • 测试版本为:2.1.2和1.5.2版本的Tengine

我用自己写的后端上传服务用nginx做反向代理,然后在 /upload/ 的location中配置了

            limit_upload_rate 500k;  
            limit_upload_rate_after 1m;

但是测试下来,上传速度还是超过了500k。

  • Nginx.conf 如下:
user              nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log;

pid        /var/run/nginx.pid;

events {
    use   epoll;
    worker_connections  1024;
}


http {
    charset utf-8;
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        '$status $body_bytes_sent "$http_referer" '
        '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    server_tokens off;
    gzip  on;

    client_header_buffer_size    8k;
    large_client_header_buffers  4 4k;


    upstream mysrv {
        server 192.168.149.20:5000;
    }


    limit_conn_zone $binary_remote_addr zone=one:10m;
    limit_req_zone $binary_remote_addr zone=req_one:10m rate=1r/s;

    server {
        listen       80;
        server_name  _;

        access_log  /var/log/nginx/domain_access.log  main; 

    location /upload {
        proxy_pass http://mysrv;
           # limit_conn one 1;
        limit_upload_rate 500k;  
            limit_upload_rate_after 1m;
            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_connect_timeout 90;
            proxy_send_timeout 90;
            proxy_read_timeout 90;


        }

        location / {
        proxy_pass http://mysrv;

            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_connect_timeout 90;   
            proxy_send_timeout 90;     
            proxy_read_timeout 90;    
            proxy_buffer_size 4k;    
            proxy_buffers 4 32k;    
            proxy_busy_buffers_size 64k; 
            proxy_temp_file_write_size 64k; 
        }

        error_page  404 403           /40x.html;
        location = /40x.html {
            root   /data;
        }

        error_page   500 502 503 504 /50x.html;  
        location = /50x.html {
            root   /data;
        }
        location ~ /\.ht {
            deny all;
        }

    }

}
Shell> ./sbin/nginx  -V 2>&1 | grep limit
configure arguments: --prefix=/root/Tengine/tengine-1.5.2 --add-module=limit_upload_rate
    ngx_http_limit_conn_module (static)
    ngx_http_limit_req_module (static)
    ngx_http_limit_upload_module (static)
@cfsego
Copy link
Owner

cfsego commented Sep 27, 2016

没有上下文。测试文件大小,测速方式等等。

@hb-lee
Copy link

hb-lee commented Jul 18, 2019

我也发限制不了,我的配置
limit_upload_rate 1k;
上传的文件为 >50K
-rw-r--r-- 1 lihongbo01 lihongbo01 52437 May 17 05:27 ngx_http.c
然后再上行服务器上运行:sar -n DEV 1 | grep -E 'IFACE|eth0' 发现设置和不设置没有影响;而对于Nginx自带的limit_rate参数的配置则可以正常的起作用

@hb-lee
Copy link

hb-lee commented Jul 18, 2019

没有上下文。测试文件大小,测速方式等等。
我也发限制不了,我的配置
limit_upload_rate 1k;
上传的文件为 >50K
-rw-r--r-- 1 lihongbo01 lihongbo01 52437 May 17 05:27 ngx_http.c
然后再上行服务器上运行:sar -n DEV 1 | grep -E 'IFACE|eth0' 发现设置和不设置没有影响;而对于Nginx自带的limit_rate参数的配置则可以正常的起作用

我是根据patch移入到openresty/1.15.8.1中的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants