首页 > 代码库 > nginx关闭图片,js,css等的日志

nginx关闭图片,js,css等的日志

一般来说这些日志的分析价值不高,而且还占用硬盘空间,一般都会关掉。

nginx配置:

     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
                        access_log off;
                        proxy_pass              http://cdel_jxjy;

                        proxy_redirect          off;
                        proxy_set_header        Host $host;
                        proxy_set_header        X-Real-IP $remote_addr;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        client_max_body_size    10m;
                        client_body_buffer_size 512k;
                        proxy_connect_timeout   300;
                        proxy_send_timeout      300;

         
                        proxy_read_timeout      300;
                        proxy_buffer_size       64k;
                        proxy_buffers           32 64k;
                        proxy_busy_buffers_size 128k;
                        proxy_temp_file_write_size 64k;
                }

                location ~ .*\.(js|css)?$ {
                        access_log off;

                        proxy_pass              http://cdel_jxjy;
                        proxy_redirect          off;
                        proxy_set_header        Host $host;
                        proxy_set_header        X-Real-IP $remote_addr;
                        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                        client_max_body_size    10m;
                        client_body_buffer_size 512k;
                        proxy_connect_timeout   300;
                        proxy_send_timeout      300;
                        proxy_read_timeout      300;
                        proxy_buffer_size       64k;
                        proxy_buffers           32 64k;
                        proxy_busy_buffers_size 128k;
                        proxy_temp_file_write_size 64k;
                }

红色的地方是必须添加的,其他的可以按照自己的需求修改。同时这里也可以进行缓存的配置:expires      30d; 可以添加到里面就可以进行缓存了

本文出自 “屌丝程序员的逆袭” 博客,请务必保留此出处http://cdelliqi.blog.51cto.com/9028667/1537546