Nginx protection against malicious stress testing
- Nginx Pressure Test method:
- # AB command
- # Install AB
- # Centos System
- Yuminstallapr-util
- # Ubuntu System
- Sudoapt-getinstallapache2-utils
- # AB Command Parameters
- -N // number of requests executed in the test session. The default value is 1.
- -C // number of requests generated at a time. The default value is 1.
- -T // The maximum number of seconds for testing. The default value is 50000.
- -P // contains the required POST data file
- -T // the Content-type Header used by the POST Data
- # Instance
- Ab-c1000-n5000http: // www.baidu.com/
- The number of 1000 concurrent requests sent each time. The total number of requests is 5000.
- ------------------------------------------------------------------------------
- # How to Set nginx to prevent stress testing:
- # Limit the maximum concurrency of the same IP address to 10
- Vim/etc/nginx. conf
- Add the first line of the http {} field:
- Limit_conn_zone $ binary_remote_addrzone = one: 10 m;
- Vim/etc/nginx/conf. d/default
- Add the server {} field:
- Limit_connone10;
- # Restart nginx
- Servicenginxrestart
- # If this error occurs, it indicates that limit_conn_zone $ binary_remote_addrzone = one: 10 m in nginx. conf;
- # Not added to the correct region, and finally added to the first line of the http field.
- Thesize10485760ofsharedmemoryzone "one" conflictswithalreadydeclaredsize0in/etc/nginx. conf: 33