Last active
March 4, 2020 21:03
-
-
Save knabben/e6d0306cea2af1a58e9334b103105e58 to your computer and use it in GitHub Desktop.
nginx with response out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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