Skip to content

Instantly share code, notes, and snippets.

@digitalist
Created November 6, 2018 13:02
Show Gist options
  • Select an option

  • Save digitalist/46ebdfd96849faca7b4804d390e55582 to your computer and use it in GitHub Desktop.

Select an option

Save digitalist/46ebdfd96849faca7b4804d390e55582 to your computer and use it in GitHub Desktop.
faking proxy_pass for POST logging with NGINX
# pin postdata as a fake upstream log format name
log_format postdata '$request_body';
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
server_name localhost;
# here we fake proxypass -> sink, so we log POST data without PHP or anything
location = /pixel.gif {
access_log /var/log/nginx/push.log postdata;
proxy_pass http://127.0.0.1/logsink;
break;
}
# it goes here and always returns SUCCESS!
location /logsink {
return 200;
}
location / { }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment