Request_body is empty in Nginx log

Source: Internet
Author: User



Deploy Nginx, look at the Nginx log, found that the value of Request_body is not recorded






Nginx log:



192.168.1.1--2016-02-24t13:33:54+08:00post/rate_plan http/1.12002----0.0020.701
192.168.1.1--2016-02-24t13:33:54+08:00post /rate_plan http/1.12002----0.0010.617
192.168.1.1--2016-02-24t13:37:44+08:00post /rate_plan http/1.12002----0.0020.502






Possible causes of the problem:



When Nginx has not yet read the request body, or if the request body is partially or completely buffered to the temporary file, $request _body and $echo _request_body will be null values.
Nginx read request body is on-demand, if using the Ngx_proxy module, read occurs in the content request processing phase. So if you read the $request _body in a phase earlier than the content phase (such as the rewrite phase), it must be null






The workaround adds two configuration entries in the nginx.conf configuration file:



Fastcgi_buffers 8k;    # Specifies how many and how large buffers are needed locally to buffer the fastcgi response. Client_body_buffer_size 1024k; #缓冲区代理缓冲用户端请求的最大字节数







worker_processes  2;
daemon off;
#pid        logs/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format  main  ‘$remote_addr$remote_user$http_user_name$time_iso8601$request‘
                      ‘$status$body_bytes_sent$request_body$http_referer$http_user_agent‘
                      ‘$http_x_forwarded_for$upstream_response_time$request_time‘;
    sendfile        on;
    keepalive_timeout  65;
    client_max_body_size 100m;
    fastcgi_buffers 32 8k;
    client_body_buffer_size 1024k;
    server {
        listen       80;
        server_name  localhost;
        charset utf-8;
        location = / {
            root html;
            index  index.html index.htm;
            error_page 405 =200 $uri;
        }
        # redirect server error pages to the static page /50x.html
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        error_page 405 =200 /index.html;
    }
    include conf.d/*.conf;
}





This article is from the "Chocolate Black" blog, be sure to keep this source http://10120275.blog.51cto.com/10110275/1744648



Request_body is empty in Nginx log


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.