NGINX - 上游响应被缓冲到临时文件

NGINX - 上游响应被缓冲到临时文件

我们从 IP 地址收到一些错误(POST 事件和上游响应缓冲区上的 500 内部错误),我们不知道这是试图提交我们的联系表单的真正客户还是垃圾邮件机器人。日志显示以下信息:

25/07/2019
    19:23:28.000 +0100  
    77.243.191.40 - - [25/Jul/2019:19:23:28 +0100] "POST /contact/ HTTP/1.0" 500 91888 "https://www. example.com/contact/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.99"
    Host: example  Name: /var/log/nginx/access.log  Category: nginx 
    2   25/07/2019
    19:23:27.000 +0100  
    77.243.191.40 - - [25/Jul/2019:19:23:27 +0100] "GET /contact/ HTTP/1.0" 200 91888 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.170 Safari/537.36 OPR/53.0.2907.99"
    Host: example  Name: /var/log/nginx/access.log  Category: nginx 
    3   24/07/2019
    18:00:49.000 +0100  
    2019/07/24 17:00:49 [warn] 20454#20454: *68024 an upstream response is buffered to a temporary file /var/lib/nginx/fastcgi/2/39/0000000392 while reading upstream, client: 77.243.191.40, server: , request: "GET /contact/ HTTP/1.0", upstream: "fastcgi://unix:/run/php/php7.0-fpm.sock:", host: "www.example.com", referrer: "https://www.example.com/contact/"
    Host: example  Name: /var/log/nginx/error.log  Category: nginx 
    4   24/07/2019
    17:00:50.000 +0100  
    77.243.191.40 - - [24/Jul/2019:17:00:50 +0100] "POST /contact/ HTTP/1.0" 500 105548 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
    Host: example  Name: /var/log/nginx/access.log  Category: nginx 
    5   24/07/2019
    17:00:49.000 +0100  
    77.243.191.40 - - [24/Jul/2019:17:00:49 +0100] "GET /contact/ HTTP/1.0" 200 105521 "https://www.example.com/contact/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.84 Safari/537.36"
    Host: example  Name: /var/log/nginx/access.log  Category: nginx 

我们的主要配置NGINX文件如下:

user www-data;
worker_processes 2;
pid /run/nginx.pid;
worker_rlimit_nofile 100000;

events {
        worker_connections 2048;
        multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

client_header_buffer_size 2k;
large_client_header_buffers 2 1k;

client_body_buffer_size 10M;
client_max_body_size 10M;

client_body_timeout 12;
client_header_timeout 12;
keepalive_timeout 15;
send_timeout 10;

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

        # server_names_hash_bucket_size 64;
   # server_name_in_redirect off;

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

        ##
        # Logging Settings
        ##

        map $http_user_agent $bot_in_log {

         ~Pingdom 0;
         ~Preload 0;
         ~Googlebot 0;
         ~Baiduspider 0;
         default 1;

        }

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";
        gzip_proxied any;
        gzip_buffers      16 8k;
        gzip_comp_level   4;
        gzip_http_version 1.0;
        gzip_min_length   1280;
        gzip_types        text/plain text/css application/x-javascript text/xml application/xml application/xml+rss a$
        gzip_vary         on;

        ##
        # Virtual Host Configs
        ##

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

}

我在另一个帖子中读到过这可能有助于解决缓冲区溢出问题,但我不确定是否应该将其添加到我们的配置中。我们正在运行一个 wordpress 网站。

proxy_buffers 16 16k;  
proxy_buffer_size 16k;

相关内容