Nginx开启访问日志但不记录图片css、js的方法

  nginx下,可以和缓存时间一起设置

    log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
    '$status $body_bytes_sent "$http_referer" '
    '"$http_user_agent" $http_x_forwarded_for';
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
         expires      30d;
         access_log off;
    }
    location ~ .*\.(js|css)?$ {
        expires      1d;
        access_log off;
    }
    access_log  /www/logs/9enjoy.com.log access;


你可能感兴趣的:(Nginx)