Ubuntu 上 nginx 的大型文件“etc/nginx/on”

Ubuntu 上 nginx 的大型文件“etc/nginx/on”

当我在 Ubuntu 环境下进行开发时,我收到一条警告,说服务器的存储空间即将用完。于是我追踪了哪个文件占用了这么多磁盘空间。我发现on下面有一个名为 的文件etc/nginx。(我使用的是 nginx )

这个文件是干什么的?这个文件占用了 7.7G,类型是 ASCII 文本,行数非常长(我用file *命令搞清楚了)

我想通过删除此文件来管理服务器的存储。这样做安全吗?我不能一直增加服务器的存储空间。

如果发现任何可疑或错误,我们将非常感激任何建议和意见。

先感谢您。

这是 nginx.conf

user www-data;
worker_processes auto;


error_log  /var/log/nginx/error.log crit;
pid        /var/run/nginx.pid;


events {
    worker_connections  4000;
    use epoll;
    multi_accept on;
}


http {
    # cache informations about FDs, frequently accessed files
    # can boost performance, but you need to test those values
    open_file_cache max=200000 inactive=20s;
    open_file_cache_valid 30s;
    open_file_cache_min_uses 2;
    open_file_cache_errors on;

    # to boost IO on HDD we can disable access logs
    access_log on;
    access_log  /var/log/nginx/access.log;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    types_hash_max_size 2048;
    server_tokens off;

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    gzip on;
    gzip_min_length 10240;
    gzip_proxied expired no-cache no-store private auth;
    #gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/json application/xml;
    gzip_types text/plain text/css application/javascript text/xml application/xml+rss;
    gzip_disable "MSIE [1-6]\.";
    gzip_vary on;

    client_body_buffer_size 10K;
    client_header_buffer_size 1k;
    client_max_body_size 20m;
    large_client_header_buffers 2 1k;

    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;

    # limit the number of connections per single IP
    limit_conn_zone $binary_remote_addr zone=conn_limit_per_ip:10m;

    # limit the number of requests for a given session
    limit_req_zone $binary_remote_addr zone=req_limit_per_ip:10m rate=5r/s;

    # zone which we want to limit by upper values, we want limit whole server
    server {
            limit_conn conn_limit_per_ip 10;
            limit_req zone=req_limit_per_ip burst=10 nodelay;

            # Expire rules for static content

            # cache.appcache, your document html and data
            location ~* \.(?:manifest|appcache|html?|xml|json)$ {
                    expires -1;
                    # access_log logs/static.log; # I don't usually include a static log
            }

            # Feed
            location ~* \.(?:rss|atom)$ {
                    expires 1h;
                    add_header Cache-Control "public";
            }

            # Media: images, icons, video, audio, HTC
            location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ {
                    expires 1M;
                    access_log off;
                    add_header Cache-Control "public";
            }

            # CSS and Javascript
            location ~* \.(?:css|js)$ {
                    expires 1y;
                    access_log off;
                    add_header Cache-Control "public";
            }

    }

    # server will close connection after this time -- default 75
    keepalive_timeout 30;

    # number of requests client can make over keep-alive -- for testing environment
    keepalive_requests 100000;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;
}

检查存储

/etc/nginx# ls -alSh
total 7.7G
-rw-r--r--   1 www-data root 7.7G Sep 20 00:36 on
drwxr-xr-x 126 root     root  12K Sep 15 16:15 ..
drwxr-xr-x   5 root     root 4.0K Jul  6 13:44 .
drwxr-xr-x   2 root     root 4.0K May 26 02:13 conf.d
drwxr-xr-x   2 root     root 4.0K Jul  6 13:42 sites-enabled
drwxr-xr-x   4 root     root 4.0K Nov 15  2016 ssl
-rw-r--r--   1 root     root 3.9K Apr 26 01:48 mime.types
-rw-r--r--   1 root     root 3.6K Sep 13  2016 win-utf
-rw-r--r--   1 root     root 3.5K Nov 19  2016 docker_default
-rw-r--r--   1 root     root 2.8K Jul  6 13:44 nginx.conf
-rw-r--r--   1 root     root 2.8K Sep 13  2016 koi-utf
-rw-r--r--   1 root     root 2.2K Sep 13  2016 koi-win
-rw-r--r--   1 root     root 1007 Sep 13  2016 fastcgi_params
-rw-r--r--   1 root     root  664 Sep 13  2016 uwsgi_params
-rw-r--r--   1 root     root  636 Sep 13  2016 scgi_params
-rw-r--r--   1 root     root  417 Dec  1  2016 Dockerfile
lrwxrwxrwx   1 root     root   22 Sep 13  2016 modules -> /usr/lib/nginx/modules

找出它是什么类型

/etc/nginx# file *
conf.d:         directory 
docker_default: ASCII text, with very long lines
Dockerfile:     UTF-8 Unicode text
fastcgi_params: ASCII text
koi-utf:        C source, ASCII text
koi-win:        C source, ASCII text
mime.types:     ASCII text
modules:        symbolic link to `/usr/lib/nginx/modules' 
nginx.conf:     ASCII text
on:             ASCII text, with very long lines
scgi_params:    ASCII text
sites-enabled:  directory 
ssl:            directory 
uwsgi_params:   ASCII text
win-utf:        C source, ASCII text

答案1

据我所知,但我可能错了,不存在这样的指令:access_log on;

我怀疑该指令使 NGinx 写入访问日志文件,on而不是你使用指定的文件access_log /var/log/nginx/access.log;

可以使用access_log off;现有指令来禁用访问日志。

要保持访问日志删除,它会将日志写入您的指令access_log on;中指定的文件中:access_logaccess_log /var/log/nginx/access.log;

回答:是的,删除此文件是安全的(或者,如果您想跟踪这些访问日志,请备份它 - 将其移动到其他地方)。

相关内容