1. server 블럭밖 설정
limit_req_zone $binary_remote_addr zone=basiclimit:10m rate=10r/s; (10m 메모리 : 160,000 ip, 초당 : 10 request, nodelay : 바로 에러 리턴)
2. server 설정
server {
listen 80;
server_name limit.test.co.kr;
access_log /var/log/nginx/limit-access.log combined;
location / {
limit_req zone=basiclimit burst=5;
proxy_pass http://127.0.0.1:8000;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
3. 테스트 (with apache benchmark)
ab -c 1 -n 200 http://www.google.com (single connection)
ab -c 4 -n 200 http://www.google.com (multi connection)
'오픈소스 > nginx' 카테고리의 다른 글
nginx tcp/application load balancing (0) | 2018.02.05 |
---|---|
nginx load balancing (0) | 2018.02.05 |
nginx cache (0) | 2018.02.05 |
nginx proxy setup (0) | 2018.02.05 |
blocking setup for nginx (0) | 2018.02.02 |