location 设定某个文件的过期时间,并不记录访问日志

时间:2023-03-09 19:49:04
location 设定某个文件的过期时间,并不记录访问日志

网页的根目录本来是: 6 root /app/www/default;

 [root@web01 default]# cat /app/server/nginx/conf/vhosts/default.conf
server {
listen ;
server_name espressos.cn;
index index.php index.htm index.html;
root /app/www/default;
location ~ .*\.(sh|bash)?$
{
return ;
}
# if (!-e $request_filename) {
# rewrite ^/(.*)$ /index.php last;
# }
location ~ .*\.(php|php5)?$
{
#fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
include /app/server/nginx/conf/rewrite/default.conf;
access_log /app/log/nginx/access/default.log;
}

参数:access_log off ------->关闭了记录这个页面的到访问日志里!!!默认是记录访问日志的。

[root@web01 default]# tree /app/www/default/
/app/www/default/ directories, files
[root@web01 default]# tree /app/www/html/
/app/www/html/
└── m.js directories, file
[root@web01 default]# cat /app/server/nginx/conf/rewrite/default.conf
#rewrite ^/index\.html /index.php last;
#if (!-e $request_filename) rewrite ^/(.*)$ index.php last;
#if (!-e $request_filename) {rewrite ^/(.*)$ /index.php last;}
#if (!-e $request_filename) {return 404;}
#if ($http_user_agent ~ Firefox) {rewrite ^(.*)?$ /nginx-Firefox/$1 break;}
#if ($http_user_agent ~ MSIE) {rewrite ^(.*)$ /nginx-MSIE/$1 break;}
#rewrite ^/(\d+)/(.+)/ /$?id=$ last;
#location ~ ^/(cron|templates)/ {deny all;break;}
#location ~ ^/data {deny all;}
location ^~ /html/m.js {access_log off;root /app/www;expires ;break;}#expires 5 有效期为5秒!!
[root@web01 default]# tail -f /app/log/nginx/access/
default.log sx.log
[root@web01 default]# tail - /app/log/nginx/access/default.log
192.168.1.10 - - [/Aug/::: +] "GET /html/%5C%22/images/upload/Image/1_07(61).jpg%5C%22 HTTP/1.1" "http://192.168.1.24/html/sql.html" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"