Nginx 启用访问日志
最编程
2024-06-03 13:49:29
...
1. vi /etc/nginx/nginx.conf
2.打开 log_format 前的注释
3.Server节点中加入
access_log logs/www_access.log main;
server { listen 80; server_name localhost;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
location / { #root html; #index index.html index.htm; } access_log logs/www_access.log main; }
4.重启Nginx,会报错,是因为没有创建日文件所在目录,建个目录就可以了
mkdir -p /usr/share/nginx/logs/
Enjoy :)...
上一篇: 配置 Nginx 访问和错误日志
下一篇: Nginx 日志配置实践(带彩蛋)
推荐阅读
-
限制访问和加强安全性的NGINX配置指南
-
使用nginx代理网页,修改页面更新后,页面内容不变。停止nginx后,发现页面仍然可以访问。
-
Nginx的跨域Content Security Policy通行设置-html强制让http的访问Https
-
如何在Linux中启用远程访问和开放端口?
-
CentOS 7安装ipvsadm和Nginx,并进行基本配置与测试 下面是重写后的段落: 1. 关闭防火墙 2. 在浏览器中输入服务器IP地址并访问 3. 修改网页内容以区分不同的服务器 4. 配置lvs/nat,使用自定义的脚本 5. 检查ipvsadm设置的规则 6. 关闭防火墙 7. 测试LVS效果。
-
深入理解LNMP系列之四:Nginx日志详细解析
-
全面指南:使用lnmp、ELK 8.5.0和GeoIP解析Nginx日志,并在2022年11月版中实现数据可视化和IP地址地图可视化
-
使用Nginx访问Tomcat中的Spring MVC应用并部署多份Spring MVC应用在同一Tomcat上
-
遇到问题:访问Nginx静态页面返回500错误
-
在Windows 10上安装CentOS 7的WSL版本并启用SSH服务进行远程访问