1、Nginx用户认证配置,添加多一层访问认证
http://www.ttlsa.com/nginx/nginx-basic-http-authentication/
2、useragent限制(防刷),
http://blog.csdn.net/qq_22929803/article/details/50724662
3、请求数限制(紫色)
http://www.jb51.net/article/120185.htm
4、Nginx黑白名单IP配置
5、配置域名访问(直接域名访问)
http://www.jb51.net/article/93756.htm
直接域名访问即
由www.yhtzabbix.com/zabbix 改为 www.yhtzabbix.com直接访问
6、反向代理配置(酒红色)
本地host配置
公网Ip 域名
4.4.4.4 www.yhtzabbix.com
红色为域名配置
蓝色为直接域名访问
紫色为黑白名单配置
user www;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
limit_req_zone $binary_remote_addr zone=one:10m rate=100r/s; ##定义一个名为one的limit_req_zone用来存储session,大小是10M内存,
limit_conn_zone $binary_remote_addr zone=addr:10m; #定义一个名为addr的limit_conn_zone用来存储session,大小是10M内存,
server {
listen 80;
server_name www.yhtzabbix.com;
if ($host != 'www.yhtzabbix.com') {
rewrite ^/(.*)$ http://yht1990.blog.51cto.com/$1 permanent;
}
location / {
#root html;
root /usr/local/nginx/html/zabbix/;
index index.php index.html index.htm;
}
location ~ \.php$ {
#root html;
root /usr/local/nginx/html/zabbix/;
allow 119.130.231.201;
deny all;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#auth_basic "nginx basic http test for ttlsa.com";
#auth_basic_user_file conf/htpasswd;
#autoindex on;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
#grafanfa反向代理配置
server {
listen 81;
server_name www.yhtgrafana.com;
limit_req zone=one burst=20 nodelay; #漏桶数为20个.也就是队列数.nodelay:不启用延迟.
limit_conn addr 120; #单个客户端ip与服务器的连接数.
location / {
proxy_pass http://172.31.98.157:3000;
}
if ($host != 'www.yhtgrafana.com') {
rewrite ^/(.*)$ http://www.baidu.com/$1 permanent;
}
}
}
漏桶数设置不能超ip与服务器的连接数
漏桶数意思为 比较你限制是每个ip请求数是10个,超过10个之后,正常情况就会返回403或者444
如果你设置了漏桶数为5,那么这个ip请求数到达10个之后,还可以增加5个,超过15个才会返回403或者444
ab压测请求数限制
yum -y install httpd-tools
ab -n 10000 -c 100 http://www.yhtgrafana.com:81/
对当前连接发出压测申请,总的压测连接数是10000。同时并发的连接数是100的。
转载于:https://blog.51cto.com/yht1990/1979268