博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx 用log_format设置日志格式
阅读量:4045 次
发布时间:2019-05-24

本文共 981 字,大约阅读时间需要 3 分钟。

1、配置文件
#vim /usr/local/nginx/conf/nginx.conf
log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘‘$status $body_bytes_sent “$http_referer” ‘‘”$http_user_agent” $http_x_forwarded_for’;
include /usr/local/nginx/conf/vhost/*.conf;
 
2、vhost中配置文件
 
#vim /usr/local/nginx/conf/vhost/web.conf
 
server
 
{
 
listen 80 default;
 
server_name www.linuxidc.com;
 
index index.html index.htm index.php;
 
root /data/httpd/linuxidc.com;
 
location ~ .*\.php?$
 
{
 
include fastcgi.conf;
 
fastcgi_pass 127.0.0.1:9000;
 
fastcgi_index index.php;
 
}
 
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
 
{
 
expires 30d;
 
}
 
location ~ .*\.(js|css)?$
 
{
 
expires 1h;
 
}
 
access_log /usr/local/nginx/logs/access.log access;
 
}
 
3、相关说明解释
 
1.$remote_addr 与$http_x_forwarded_for 用以记录客户端的ip地址;
 
2.$remote_user :用来记录客户端用户名称;
 
3.$time_local : 用来记录访问时间与时区;
 
4.$request : 用来记录请求的url与http协议;
 
5.$status : 用来记录请求状态;成功是200,
 
6.$body_bytes_s ent :记录发送给客户端文件主体内容大小;
 
7.$http_referer :用来记录从那个页面链接访问过来的;
 
8.$http_user_agent :记录客户端浏览器的相关信息;linux

转载地址:http://lgqdi.baihongyu.com/

你可能感兴趣的文章
GitHub 万星推荐:黑客成长技术清单
查看>>
可以在线C++编译的工具站点
查看>>
关于无人驾驶的过去、现在以及未来,看这篇文章就够了!
查看>>
所谓的进步和提升,就是完成认知升级
查看>>
为什么读了很多书,却学不到什么东西?
查看>>
长文干货:如何轻松应对工作中最棘手的13种场景?
查看>>
如何用好碎片化时间,让思维更有效率?
查看>>
No.147 - LeetCode1108
查看>>
No.174 - LeetCode1305 - 合并两个搜索树
查看>>
No.175 - LeetCode1306
查看>>
No.176 - LeetCode1309
查看>>
No.182 - LeetCode1325 - C指针的魅力
查看>>
mysql:sql alter database修改数据库字符集
查看>>
mysql:sql truncate (清除表数据)
查看>>
yuv to rgb 转换失败呀。天呀。谁来帮帮我呀。
查看>>
yuv420 format
查看>>
YUV420只绘制Y通道
查看>>
yuv420 还原为RGB图像
查看>>
LED恒流驱动芯片
查看>>
驱动TFT要SDRAM做为显示缓存
查看>>