nginx日志常用查看语句
即时查看最近10条日志
tail -10f www_access.log
即时查看最近10条包含关键字日志
tail -10f www_access.log|grep 'search'
最近100条按$7分组排序
tail -n 100 www_access.log |awk '{print $7}'| sort -rn | more
tail -n 1000 www_access.log |awk '{print $3}'| sort|uniq -c| sort -rn | more
conf文件中设置屏蔽机器人或ip
if ($http_user_agent ~ "SemrushBot") { return 500; }
if ($http_x_forwarded_for ~* "23.226.77.138") {return 500;}
if ($remote_addr ~* "64.124.8.") {return 500;}