最近要用到nginx的访问日志,我的想法是只要记录到html页面即可,忽略图片、css和js,但配置一直不成功,求帮助。
我的配置如下:
...
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
# access_log /usr/logs/nginx/access.log main;
....
server {
listen 80;
server_name gw.test333.com;
#charset koi8-r;
access_log /usr/logs/nginx/access.log main;
error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location / {
root html;
index index.html;
access_log /usr/logs/nginx/access.log main;
}
location /images/ { #这里只试一下忽略图片先,因为我的图片连接URL里面肯定有/images/所以此处这样配置,匹配扩展的做法我也试过,不行
root html;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { # 扩展名写法
.............