Nginx配置
来源:互联网 发布:smtp.qq.com端口号 编辑:程序博客网 时间:2024/05/16 05:36
配置日志
自定义格式:
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';
$remote_addr 和 $http_x_forwarded_for :用于记录IP地址,拿到的将是反向代理服务器的IP地址;
$time_local:用于记录访问时间与时区;
$request:用于记录访问URL与http协议;
$status:用于记录请求状态,成功为200,页面找不到为404;
$body_bytes_sent:用于记录发送给客户端的文件主体内容的大小;
$http_referer:用于记录是从哪个页面链接访问过来的;
$http_user_agent:用于记录客户端浏览器的相关信息。
access_log指令设置日志的存放路径:
access_log path [format [buffer=size|off]]
path:日志存放路径
format: log_format指令设置的日志格式名称,如上面设置的名称为main
buffer=size,设置内存缓冲区的大小,不想记录日志就用
access_log off;
定时切割日志脚本:cut_nginx_log.sh
#!/bin/bash# This script run at 00:00# The angix log pathlogs_path=“/var/log/nginx/”mkdir –p ${logs_path}$(data –d “yesterday” + “%Y”)/$(data –d “yesterday” + “%m”)/mv ${logs_path}access_log ${logs_path}$(date –d “yesterday” + “%Y”)/$(date –d “yesterday” + “%m”)/access_$(date –d “yesterday” + “%Y”)/$(date –d “yesterday” + “%m”)/access_$(date –d “yesterday” + “%Y%m%d”).logkill –USR1 ‘cat /run/nginx.pid’
设置crontab,每天凌晨00:00切割日志
crontab -e
输入以下内容:
00 00 * * * /bin/bash /var/log/nginx/cut_nginx_log.sh
1 0
- Varnish+Nginx 配置----Nginx
- Nginx-配置-nginx.conf
- 【Nginx】Nginx配置优化
- 105 nginx nginx 配置
- nginx nginx.conf 配置
- nginx 配置
- nginx 配置
- Nginx配置
- nginx配置
- NGINX配置
- nginx配置
- Nginx配置
- nginx配置
- nginx配置
- nginx 配置
- nginx 配置
- nginx配置
- Nginx配置
- 自己动手写RTP服务器——关于RTP协议
- 收藏关于React-Native的学习指南
- 一些很有用的开源项目
- 并行计算—OpenMP—负载均衡
- Gym 101138I Prime Moving【素数测试】
- Nginx配置
- Linux 性能监控
- 代码书写规范
- RDS for MySQL 备份文件恢复到自建数据库遇到启动问题
- 搜狗输入法安装之后无法使用
- 小知识-MySql的读写分离
- 坚持
- RN listView使用
- android多进程