004.Nginx日志配置及状态监控
一 Nginx请求简介
1.1 请求头部
1 [root@nginx ~]# curl -v www.odocker.com
2 * About to connect() to www.odocker.com port 80 (#0) #关于本次连接信息
3 * Trying 113.31.119.149...
4 * Connected to www.odocker.com (113.31.119.149) port 80 (#0)
5 > GET / HTTP/1.1 #HTTP版本
6 > User-Agent: curl/7.29.0 #客户端信息
7 > Host: www.odocker.com #请求的服务端主机
8 > Accept: */* #如上为请求
9 >
10 < HTTP/1.1 200 OK #返回http版本
11 < Server: nginx/1.16.1 #服务端Web类型
12 < Date: Fri, 06 Mar 2020 13:09:40 GMT #日期时间
13 < Content-Type: text/html #返回的类型
14 < Content-Length: 13 #长度
15 < Last-Modified: Thu, 05 Mar 2020 11:12:26 GMT #日期时间
16 < Connection: keep-alive #长连接
17 < ETag: "5e60de9a-d" #Etag
18 < Accept-Ranges: bytes #大小单位
19 <
20 <h1>www</h1> #具体内容
21 * Connection #0 to host www.odocker.com left intact
二 日志配置
2.1 日志相关配置
2.2 access_log配置
- access_log path [format [buffer=size [flush=time]]];
- access_log path format gzip[=level] [buffer=size] [flush=time];
- access_log syslog:server=address[,parameter=value] [format];
- access_log off; #不记录日志
- gzip:压缩等级。
- buffer:设置内存缓存区大小。
- flush:保存在缓存区中的最长时间。
2.3 log_format配置
- log_format name string ……;
1 ……
2 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
3 '$status $body_bytes_sent "$http_referer" '
4 '"$http_user_agent"';
5 ……
1 ……
2 log_format proxy '$remote_addr - $remote_user [$time_local] "$request" '
3 '$status $body_bytes_sent "$http_referer" '
4 '"$http_user_agent" "$http_user_agent" ';
5 ……
2.4 open_log_file_cache配置
- open_log_file_cache max=N [inactive=time] [min_uses=N] [valid=time];
- open_log_file_cache off;
2.5 log_not_found配置
2.6 log_subrequest配置
2.7 rewrite_log配置
2.8 error_log配置
三 状态监控
3.1 配置监控
1 [root@nginx01 ~]# vi /etc/nginx/conf.d/status.conf
2 server {
3 server_name status.linuxds.com;
4
5 error_page 404 403 500 502 503 504 /error.html;
6 location = /error.html {
7 root /usr/share/nginx/html;
8 }
9
10 location / {
11 root /usr/share/nginx/blog;
12 index index.html;
13 }
14 location /ok {
15 alias /usr/share/nginx/yes;
16 index index.html;
17 }
18 location /mystatus {
19 stub_status on;
20 access_log off;
21 }
22 }
1 [root@nginx01 ~]# nginx -t -c /etc/nginx/nginx.conf
2 [root@nginx01 ~]# nginx -s reload

- Active connections:当前活跃的连接数。
- server:表示Nginx启动到现在共处理了90个连接。
- accepts:表示Nginx启动到现在共成功创建90次握手。
- handled requests:表示总共处理了19次请求。
- Reading:Nginx读取到客户端的 Header 信息数。
- Writing:Nginx返回给客户端的 Header 信息数。
- Waiting:Nginx开启keep-alive长连接情况下, 既没有读也没有写, 建立连接情况。
004.Nginx日志配置及状态监控的更多相关文章
- nginx日志配置
nginx日志配置 http://www.ttlsa.com/linux/the-nginx-log-configuration/ 日志对于统计排错来说非常有利的.本文总结了nginx日志相关的配置如 ...
- (转)nginx日志配置指令详解
这篇文章主要介绍了nginx日志配置指令详解,nginx有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志,需要的朋友可以参考下日志对于统计排错来说非常有利的.本文总结了nginx日 ...
- nginx日志配置指令详解
这篇文章主要介绍了nginx日志配置指令详解,nginx有一个非常灵活的日志记录模式,每个级别的配置可以有各自独立的访问日志,需要的朋友可以参考下日志对于统计排错来说非常有利的.本文总结了nginx日 ...
- Nginx https加密以及nginx日志配置与管理
Nginx https加密以及nginx日志配置与管理 使用Nginx的优点Nginx作为WEB服务器,Nginx处理静态文件.索引文件.自动索引的效率非常高.Nginx作为代理服务器,Nginx可以 ...
- nginx日志配置[转]
* * * sh /home/zyf/sh/cut_nginx_log.sh 这样就每天的0点1分把nginx日志重命名为日期格式,并重新生成今天的新日志文件。 日志对于统计排错来说非常有利的。本文 ...
- Nginx日志配置及日志切割
日志配置 日志对于统计排错来说非常有利的.本文总结了nginx日志相关的配置如access_log.log_format.open_log_file_cache.log_not_found.log_s ...
- 死磕nginx系列-nginx日志配置
nginx access日志配置 access_log日志配置 access_log用来定义日志级别,日志位置.语法如下: 日志级别: debug > info > notice > ...
- Nginx日志配置与切割
访问日志主要记录客户端访问Nginx的每一个请求,格式可以自定义.通过访问日志,你可以得到用户地域来源.跳转来源.使用终端.某个URL访问量等相关信息. Nginx中访问日志相关指令主要有两条,一条是 ...
- nginx别名配置,状态配置,include优化
一.nginx帮助参数 下面是关于/application/nginx/sbin/nginx 的参数帮助 [root@A conf]# /application/nginx/sbin/nginx -h ...
随机推荐
- 重学 Java 设计模式:实战中介者模式「按照Mybaits原理手写ORM框架,给JDBC方式操作数据库增加中介者场景」
作者:小傅哥 博客:https://bugstack.cn - 原创系列专题文章 沉淀.分享.成长,让自己和他人都能有所收获! 一.前言 同龄人的差距是从什么时候拉开的 同样的幼儿园.同样的小学.一样 ...
- dart快速入门教程 (5)
5.函数 5.1.函数定义 语法: 返回值类型 函数名(参数类型 参数1, 参数类型 参数2,...) { // 函数体 return '返回值' } 举例: void main() { print( ...
- 如何在Mac中配置Python虚拟环境,踩了好多坑
如何在Mac中配置Python虚拟环境 1.安装virtualenv pip3 install virtualenv 2.安装virtualenvwrapper pip3 install virtua ...
- Qt-绘图
1 简介 参考视频:https://www.bilibili.com/video/BV1XW411x7NU?p=37 参考文档:<Qt教程.docx> 本文简单介绍Qt的绘图与绘图设备. ...
- 状压dp大总结1 [洛谷]
前言 状态压缩是一种\(dp\)里的暴力,但是非常优秀,状态的转移,方程的转移和定义都是状压\(dp\)的难点,本人在次总结状压dp的几个题型和例题,便于自己以后理解分析状态和定义方式 状态压缩动态规 ...
- CF3D Least Cost Bracket Sequence 贪心
Least Cost Bracket Sequence CodeForces - 3D 题目描述 This is yet another problem on regular bracket sequ ...
- java NIO 原理解析之学习笔记
关键抽象 1.Buffer缓冲区 NIO数据传递模型,是一个连续的内存区域.所有数据传递均通过buffer类处理:NIO提供了字符串.整形.字节.堆等多种缓冲区. 2.Channel(通道) NIO把 ...
- 基于SpringBoot AOP面向切面编程实现Redis分布式锁
基于SpringBoot AOP面向切面编程实现Redis分布式锁 基于SpringBoot AOP面向切面编程实现Redis分布式锁 基于SpringBoot AOP面向切面编程实现Redis分布式 ...
- List的isEmpty与==null的区别
集合的判空一般判定方法 ArrayList<Person> list = null; System.out.println(null == list);//return true Syst ...
- AbstractQueuedSynchronizer(AQS)抽丝剥茧深入了解JUC框架原理
目录 简介 Lock简单实用 主体框架 原理解析 独占锁 AQS数据结构 CLH数据结构 acquire实现步骤 addWaiter acquireQueued shouldParkAfterFail ...