nginx logging all post data

開發在問說他們為debug需要想要記錄post 的data,在 nginx 中很簡單

只要在 log format 及所要記錄的 location 加上記錄即可

modify nginx.conf

 log_format postdata escape=json '$remote_addr - [$time_local] - "$request" - "$request_body"';
#處理 php的 handler
location ~ \.php$ {
    fastcgi_index index.php;
    # Please disable if not in debug mode to avoid the logs size greater..
      if ($request_method = POST) {
        access_log  /var/log/nginx/postdata.log  postdata;



Author: jerryw1974

learning and focus on computer science, cloud infrastructure, virtualization and information security, technical, networking,platform system and cyber-security related topic.