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


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

     1 [root@web01 default]# cat /app/server/nginx/conf/vhosts/default.conf
     2 server {
     3         listen       80;
     4         server_name  espressos.cn;
     5     index index.php index.htm index.html;
     6     root /app/www/default;
     7     location ~ .*.(sh|bash)?$ 
     8     {
     9         return 403;
    10     }
    11 #    if (!-e $request_filename) {
    12 #        rewrite ^/(.*)$ /index.php last;
    13 #        }
    14     location ~ .*.(php|php5)?$
    15     {
    16         #fastcgi_pass  unix:/tmp/php-cgi.sock;
    17         fastcgi_pass  127.0.0.1:9000;
    18         fastcgi_index index.php;
    19         include fastcgi.conf;
    20     }
    21     location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
    22     {
    23         expires 30d;
    24     }
    25     location ~ .*.(js|css)?$
    26     {
    27         expires 1h;
    28     }
    29     include /app/server/nginx/conf/rewrite/default.conf;
    30     access_log  /app/log/nginx/access/default.log;
    31 }

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

    [root@web01 default]# tree /app/www/default/
    /app/www/default/
    
    0 directories, 0 files
    [root@web01 default]# tree /app/www/html/
    /app/www/html/
    └── m.js
    
    0 directories, 1 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+)/(.+)/ /$2?id=$1 last;
    #location ~ ^/(cron|templates)/ {deny all;break;}
    #location ~ ^/data {deny all;}
    location ^~ /html/m.js {access_log off;root /app/www;expires 5;break;}#expires 5 有效期为5秒!!
    [root@web01 default]# tail -f /app/log/nginx/access/
    default.log  sx.log       
    [root@web01 default]# tail -1 /app/log/nginx/access/default.log 
    192.168.1.10 - - [01/Aug/2016:21:22:57 +0800] "GET /html/%5C%22/images/upload/Image/1_07(61).jpg%5C%22 HTTP/1.1" 404 168 "http://192.168.1.24/html/sql.html" "Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"
  • 相关阅读:
    在centos上搭建Git服务器
    glog日志库移植Android平台
    水葱
    路易斯安娜鸢尾
    再力花
    矮生百慕大
    洒金珊瑚
    八角金盘
    锦绣杜鹃
    茶梅球
  • 原文地址:https://www.cnblogs.com/bass6/p/5728685.html
Copyright © 2020-2023  润新知