zoukankan      html  css  js  c++  java
  • 12.10 Nginx访问日志 12.11 Nginx日志切割 12.12 静态文件不记录日志和过期时间

    可以自己定义

    [root@lizhipenglinux01 vhost]# pwd
    /usr/local/nginx/conf/vhost
    [root@lizhipenglinux01 vhost]# vim test.com.conf

    server
    {
    listen 80;
    server_name test.com test2.com test3.com;
    index index.html index.htm index.php;
    root /data/wwwroot/test.com;
    if ($host != 'test.com' ) {
    rewrite ^/(.*)$ http://test.com/$1 permanent;
    }
    access_log /tmp/test.com.log aming;     //增加了这一行
    }

    [root@lizhipenglinux01 vhost]# /usr/local/nginx/sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [root@lizhipenglinux01 vhost]# /usr/local/nginx/sbin/nginx -s reload
    [root@lizhipenglinux01 vhost]# curl -x127.0.0.1:80 test3.com/admin/index.html -I
    HTTP/1.1 301 Moved Permanently
    Server: nginx/1.12.1
    Date: Sun, 11 Mar 2018 21:48:47 GMT
    Content-Type: text/html
    Content-Length: 185
    Connection: keep-alive
    Location: http://test.com/admin/index.html

    [root@lizhipenglinux01 vhost]# curl -x127.0.0.1:80 test2.com/admin/index.html -I
    HTTP/1.1 301 Moved Permanently
    Server: nginx/1.12.1
    Date: Sun, 11 Mar 2018 21:48:57 GMT
    Content-Type: text/html
    Content-Length: 185
    Connection: keep-alive
    Location: http://test.com/admin/index.html

    [root@lizhipenglinux01 vhost]# cat /tmp/test.com.log
    127.0.0.1 - [12/Mar/2018:05:48:47 +0800] test3.com "/admin/index.html" 301 "-" "curl/7.29.0"
    127.0.0.1 - [12/Mar/2018:05:48:57 +0800] test2.com "/admin/index.html" 301 "-" "curl/7.29.0"

    [root@lizhipenglinux01 vhost]# crontab -e                任务计划
    no crontab for root - using an empty one

    0 0 * * * /bin/bash /usr/local/sbin/nginx_log_rotate.sh

     

    [root@lizhipenglinux01 vhost]# /usr/local/nginx/sbin/nginx -t
    nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
    nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
    [root@lizhipenglinux01 vhost]# /usr/local/nginx/sbin/nginx -s reload

    [root@lizhipenglinux01 vhost]# cd /data/wwwroot/test.com/
    [root@lizhipenglinux01 test.com]# ls
    admin index.html
    [root@lizhipenglinux01 test.com]# vim 1.gif
    [root@lizhipenglinux01 test.com]# vim 2.js
    [root@lizhipenglinux01 test.com]# vim 1.gif
    [root@lizhipenglinux01 test.com]# vim 2.js
    [root@lizhipenglinux01 test.com]# curl -x127.0.0.1:80 test.com/1.gif
    ddsefsonf
    [root@lizhipenglinux01 test.com]# curl -x127.0.0.1:80 test.com/2.js
    jnmslmc
    [root@lizhipenglinux01 test.com]#

    [root@lizhipenglinux01 test.com]# curl -x127.0.0.1:80 test.com/index.html
    test.com
    [root@lizhipenglinux01 test.com]# cat /tmp/test.com.log
    127.0.0.1 - [12/Mar/2018:06:25:41 +0800] test.com "/index.html" 200 "-" "curl/7.29.0"

    [root@lizhipenglinux01 test.com]# curl -x127.0.0.1:80 test.com/index.html
    test.com
    [root@lizhipenglinux01 test.com]# cat /tmp/test.com.log
    127.0.0.1 - [12/Mar/2018:06:25:41 +0800] test.com "/index.html" 200 "-" "curl/7.29.0"
    127.0.0.1 - [12/Mar/2018:06:27:02 +0800] test.com "/index.html" 200 "-" "curl/7.29.0"

    [root@lizhipenglinux01 test.com]# curl -x127.0.0.1:80 test.com/2.js
    jnmslmc
    [root@lizhipenglinux01 test.com]# cat /tmp/test.com.log              没有2.js的记录
    127.0.0.1 - [12/Mar/2018:06:25:41 +0800] test.com "/index.html" 200 "-" "curl/7.29.0"
    127.0.0.1 - [12/Mar/2018:06:27:02 +0800] test.com "/index.html" 200 "-" "curl/7.29.0"

    注释掉expires

    没有了cache

  • 相关阅读:
    为什么 ObjectiveC 很难
    PHP开发Windows桌面应用程序实例
    windows下借助InstantRails环境搭建redmine
    php,python,ruby,perl的优缺点?
    Ruby在windows上的eclipse开发环境搭建
    Python的web框架很多,比如Django,webpy等,但是哪一种综合实力最强呢?
    使用JRockit作为Eclipse的Java VM
    Fat Jar Eclipse PlugIn Tutorial
    ECLIPSE插件集合
    Java反编译利器Jad, Jode, Java Decompiler等及其IDE插件
  • 原文地址:https://www.cnblogs.com/sisul/p/8546717.html
Copyright © 2011-2022 走看看