Nginx限制IP访问
先做一个clientRealIp变量,clientRealIp用http_x_forwarded_for的第一个IP 1234map $http_x_forwarded_for $clientRealIp { "" $remote_addr; ~^(?P<firstAddr>[0-9\.]+),?.*$ $firs
先做一个clientRealIp变量,clientRealIp用http_x_forwarded_for的第一个IP 1234map $http_x_forwarded_for $clientRealIp { "" $remote_addr; ~^(?P<firstAddr>[0-9\.]+),?.*$ $firs
创建nginx.repo 1vim /etc/yum.repos.d/nginx.repo 输入 12345[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/$releasever/$basearch/
5分钟时间窗口,上游服务response time大于1秒的数量 1*| SELECT time_series(__time__, '5m', '%Y-%m-%d %H:%i:%s' ,'0') as Time, count(1) as T where upstream_response_time > 1 group by Time order
配置Nginx 1vim /etc/nginx/nginx.conf Nginx新增一个日志格式 123log_format timed_combined '$remote_addr - $remote_user [$time_local] "$request" $http_host ' '$status $request_length $body_bytes_sent "$http_referer" ' '"$http_user_agent" $request_time $upstream_response_time "$sent_http_content_type"'; 设置日志输出路径 1access_log /var/log/nginx/aliyun.log timed_combined; 重新加载Nginx 1nginx -s reload