Skip to content

Instantly share code, notes, and snippets.

@knabben
Last active March 4, 2020 21:03
Show Gist options
  • Save knabben/e6d0306cea2af1a58e9334b103105e58 to your computer and use it in GitHub Desktop.
Save knabben/e6d0306cea2af1a58e9334b103105e58 to your computer and use it in GitHub Desktop.
nginx with response out
http {
include mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
log_format log_1 'x $request_body - $resp_body';
server {
listen 8080;
access_log logs/access.log log_1;
lua_need_request_body on;
set $resp_body "";
body_filter_by_lua_block {
local resp_body = ngx.arg[1]
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body
if ngx.arg[2] then
ngx.var.resp_body = ngx.ctx.buffered
end
}
location / {
default_type "text/plain";
content_by_lua_block {
ngx.print("hello");
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment