您的位置:首页 > 运维架构 > Nginx

nginx限制访问频率

2015-07-16 10:17 531 查看
修改服务器上的nginx的配置文件/usr/local/nginx/conf/nginx.confhttp { limit_req_zone $binary_remote_addr zone=one:10m rate=3000r/m; proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m; proxy_temp_path /var/tmp;
include mime.types; default_type application/octet-stream;
gzip on; gzip_comp_level 6; gzip_vary on; gzip_min_length 1000; gzip_proxied any; gzip_types text/plain text/html text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; gzip_buffers 16 8k;
#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 logs/access.log main;
sendfile on; #tcp_nopush on;
#keepalive_timeout 0; keepalive_timeout 65;
#gzip on;
upstream wedate{ server 10.0.0.48:8080; server 10.0.0.50:8080; } server { listen 8080; server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / { limit_req zone=wedate_zone burst=30; proxy_redirect off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Host $http_host; proxy_set_header X-NginX-Proxy true; proxy_set_header Connection ""; proxy_http_version 1.1; proxy_cache one; proxy_cache_key sfs$request_uri$scheme; proxy_pass http://wedate; }nginx平滑重启、 nginx -t -c /usr/local/nginx/conf/nginx.conf
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: