• 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"
  • 相关阅读:
    显示数据库中的数据
    C# 替换去除HTML标记方法(正则表达式)
    aspx,ascx和ashx使用总结
    groupby用法
    C#的一个URL加载器,能处理编码、相对地址解析、GET/POST、HTML的include、页面重定向
    js调用WebService的例子
    跨站点的单点登录
    新安装的Centos7不能联网且ifconfig出现command not found
    virtualbox桥接网卡设置
    2012暑假Ajax学习笔记
  • 原文地址:https://www.cnblogs.com/bass6/p/5728685.html
Copyright © 2020-2023  润新知