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

smc*_*hae 2 ubuntu nginx

当我在 Ubuntu 环境下开发时,我收到一个警报,说服务器很快就会耗尽存储空间。所以我追踪了哪个文件在磁盘上占用了这么多空间。我能找到,有一个命名的文件onetc/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/*;
}
Run Code Online (Sandbox Code Playgroud)

检查存储

/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
Run Code Online (Sandbox Code Playgroud)

找出它是什么类型

/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
Run Code Online (Sandbox Code Playgroud)

kri*_*sFR 5

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

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

可以使用 禁用访问日志access_log off;,这是一个现有的指令。

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

回答:是的,删除这个文件是安全的(或者备份它 - 将它移到别处 - 如果你想跟踪这些访问日志)。