nginx过滤访问日志

[root@localhost vhost]# vi 1.com.conf
 

server
{
   listen 8080;
   server_name www.123.com;
   index index.html;
   root /data/wwwroot/1.com;
   rewrite_log on;
  location /
  {
        rewrite /123.html /1.html redirect;
        error_log /tmp/nginx.err debug;
        
   }
   location ~* '(css|js|png|jpg|gif|rar|mp4|bmp)$'
   {
       access_log off;
      # access_log /dev/null;
   }
       access_log /tmp/123.com.log aming;

}

[root@localhost vhost]# curl -x127.0.0.1:8000 www.123.com/123.css -I
HTTP/1.1 404 Not Found
Server: nginx/1.8.0
Date: Wed, 26 Feb 2020 05:56:31 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

[root@localhost vhost]# cat /tmp/123.com.log
127.0.0.1 - [26/Feb/2020:11:31:14 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
127.0.0.1 - [26/Feb/2020:11:46:25 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
[root@localhost vhost]# curl -x127.0.0.1:8000 www.123.com/123.css1 -I
HTTP/1.1 404 Not Found
Server: nginx/1.8.0
Date: Wed, 26 Feb 2020 05:57:28 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

[root@localhost vhost]# cat /tmp/123.com.log
127.0.0.1 - [26/Feb/2020:11:31:14 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
127.0.0.1 - [26/Feb/2020:11:46:25 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
10.133.254.205 127.0.0.1, 10.133.254.205 [26/Feb/2020:13:57:28 +0800] www.123.com "/123.css1" 404 "-" "curl/7.29.0"

[root@localhost vhost]# curl -x127.0.0.1:8000 www.123.com/123.g1if -I
HTTP/1.1 404 Not Found
Server: nginx/1.8.0
Date: Wed, 26 Feb 2020 06:03:14 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive

[root@localhost vhost]# cat /tmp/123.com.log
127.0.0.1 - [26/Feb/2020:11:31:14 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
127.0.0.1 - [26/Feb/2020:11:46:25 +0800] www.123.com "/123.html" 302 "-" "curl/7.29.0"
10.133.254.205 127.0.0.1, 10.133.254.205 [26/Feb/2020:13:57:28 +0800] www.123.com "/123.css1" 404 "-" "curl/7.29.0"
10.133.254.205 127.0.0.1, 10.133.254.205 [26/Feb/2020:14:03:14 +0800] www.123.com "/123.g1if" 404 "-" "curl/7.29.0"

 
来源: 营销

猜你喜欢

转载自www.cnblogs.com/1994jinnan/p/12366917.html