配置: CPU2核、内存4GB 镜像: Windows Server 2008 R2 标准版 SP1 64位中文版 存储: 1块普通云盘(100GB) 网络: 带宽10Mbps(经典网络)
map $http_x_forwarded_for $clientRealIp {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}
# 访问受限制后返回599
limit_req_status 599;
# 定义一个名为allips的limit_req_zone用来存储session,大小是100M内存,
# 以$clientRealIp 为key,限制平均每秒的请求为100个,
limit_req_zone $clientRealIp zone=allips:100m rate=100r/s;
server {
listen 1334;
server_name _;
# 添加如下一行
limit_req zone=allips burst=5 nodelay;
location / {
# 反向代理
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://wskh_IIS;
}
# 开启stub_status模块监控
location /nginx_status{
stub_status on;
access_log off;
allow 127.0.0.1;
# 允许内网某IP查看nginx status
allow 192.168.1.100;
deny all;
}
}
# 后端web服务器
upstream wskh_IIS {
server 192.168.1.39:1334;
server 192.168.1.40:1334;
ip_hash;
}
#!/bin/bash
#
# Filename: count_req.sh
# Revision: 1.0
# Author: Qicheng
# Website: http://qicheng0211.blog.51cto.com
# Description: 统计Nginx日志里IP访问频率
NGINXLOG="./access.log"
start_time=$(head -n1 "$NGINXLOG" | grep -o " \[.*\] ")
stop_time=$(tail -n1 "$NGINXLOG" | grep -o " \[.*\] ")
echo -e "start:\t\e[92m$start_time\033[0m"
echo -e "stop:\t\e[92m$stop_time\033[0m"
echo '所有的请求TOP50-->>'
# 所有的请求
cat "$NGINXLOG" | awk '{++S[$1]} END {for(a in S) print S[a],"\t", a}' | sort -rn -k1 | head -n 50
echo '--------------------------------------------------'
echo '成功的请求TOP50-->>'
# 成功的请求
grep ' 200 ' "$NGINXLOG" | awk '{++S[$1]} END {for(a in S) print S[a],"\t", a}' | sort -rn -k1 | head -n 50
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有