Skip to content

Instantly share code, notes, and snippets.

@jefflab
Created July 2, 2015 02:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jefflab/01f592a4c4754433d65d to your computer and use it in GitHub Desktop.
Save jefflab/01f592a4c4754433d65d to your computer and use it in GitHub Desktop.
nginx conf that capture body for specific location:
```
http {
log_format l2met 'measure#nginx.service=$request_time request_id=$http_x_request_id';
log_format capturebody "request_body = $request_body";
access_log logs/nginx/access.log l2met;
error_log logs/nginx/error.log;
server {
location /path/to/log {
set $xxxx $request_body;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
access_log logs/nginx/access.log capturebody;
}
location / {
set $xxxx "NOT_LOGGED";
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://app_server;
}
}
}
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment