[英]How to get user-agent, referrer from nginx error log
guys, 伙计们,
I see a lot of errors like the following in my nginx's error.log
: 我在nginx的error.log
看到很多类似以下的错误:
2016/01/06 15:57:41 [error] 9054#0: *381280040 open() "/mypath/current/public/images/default_avatar.png" failed (2: No such file or directory), client: 222.83.227.19, server: mydomain.com, request: "GET //images/default_avatar.png HTTP/1.1", host: "www.mydomain.com"
But I could not find a place where I've wrongly referred to the image. 但是我找不到错误地引用图像的地方。 Is there a way that I could print the user-agent
and referrer
of this request, so that I could find out where I've done wrong? 有没有一种方法可以打印此请求的user-agent
和referrer
,以便找出错误的地方?
Best Regards. 最好的祝福。 Larry 拉里
您可能会寻找log_format
的定义位置,然后添加"$http_referer" "$http_user_agent"
。
You can use access_log
to log requests with HTTP status codes 4xx (Client errors) and 5xx (Server errors) except 499 which is nginx Status code for client connection close. 您可以使用access_log
记录HTTP状态代码为 4xx(客户端错误)和5xx(服务器错误)的请求,但499(nginx客户端连接关闭的状态代码)除外。
#access_log off;
map $status $loggable {
~^[45] 1;
499 0; # client closed connection
default 0;
}
access_log /var/log/nginx/error.log combined if=$loggable;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.