如何从NGINX打印request_body和response_body

时间:2018-08-08 07:20:12

标签: nginx nginx-location nginx-reverse-proxy nginx-config nginx-log

我想从NGINX打印request_body和response_body。

我尝试实施从 here

中学到的一些解决方案

但是对于我来说,它不起作用。我需要在 NGINX.conf 文件中配置一些其他更改。

这是我的配置文件。

worker_processes 4;

events { worker_connections 1024; }

http {

    sendfile on;

    upstream consumer-portal {
        server xx.xx.xx.xx:9006;
    }
     upstream download-zip-service {
        server xx.xx.xx.xx:9012;
    }
server {
        listen 8765;

        location / {
            proxy_pass         http://download-zip-service/;
            proxy_redirect     off;
            # proxy_set_header   Host $host;
            # proxy_set_header   X-Real-IP $remote_addr;
            # proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            # proxy_set_header   X-Forwarded-Host $server_name;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            #socket timeout setting added
            fastcgi_read_timeout 7200s; 
            send_timeout 7200s;
            proxy_connect_timeout 7200s;
            proxy_send_timeout 7200s;
            proxy_read_timeout 7200s;
            #new property added
            proxy_request_buffering off;
            proxy_buffering off;
        }
        location /consumer-portal/ {
            proxy_pass         http://consumer-portal/;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    }
}

下面是docker-compose.yml

version: '3'
services:
  nginx:
    restart: always
    build: ../../conf/sandbox/
    volumes:
    - ./mysite.template:/etc/nginx/conf.d/mysite.template
    ports:
    - "8765:8765"
    networks:
      - cloud


networks:
  cloud:
   driver: bridge

请让我知道我需要配置哪些更改。

谢谢。

0 个答案:

没有答案