nginx速率限制不起作用

时间:2017-08-11 03:06:15

标签: android nginx

我有一个简单的nginx配置,具有访问速率限制,但速率限制仅适用于/ location,而不是/ android / nor / ios /,任何人都可以帮助,谢谢。例如,app.xyz.com是有限的,但app.xyz.com/android/abc/de/s.apk不受限制。谢谢你的解释。

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;
    limit_req_zone $binary_remote_addr zone=one:10m rate=1r/m;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;
    include /etc/nginx/conf.d/*.conf;

    server {
        listen 80;
        server_name  app.xyz.com;
        return 301 https://$host$request_uri;
    }

    server {
        listen       443 ssl http2;
        server_name  app.xyz.com;
        access_log  /var/log/nginx/www.access.log  main;
        ssl_certificate /etc/letsencrypt/live/app.xyz.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/app.xyz.com/privkey.pem;
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers on;

        location / {
            limit_req zone=one burst=3 nodelay;
            root   /usr/share/nginx/html;
            index  index.html index.htm;
        }

        location /android/ {
            limit_req zone=one burst=3 nodelay;
        }

        location /ios/ {
            limit_req zone=one burst=3 nodelay;
        }

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

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }

    }

}

0 个答案:

没有答案