Created
December 20, 2015 08:55
-
-
Save yuki-takeichi/282950a7f079fc223156 to your computer and use it in GitHub Desktop.
Nginx reverse proxy for debugging
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
worker_processes 1; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format bodylog '$remote_addr - $remote_user [$time_local] ' | |
'"$request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent" $request_time ' | |
'<"$request_body" >"$resp_body"'; | |
server { | |
listen 8080; | |
server_name localhost; | |
# http://serverfault.com/questions/361556/is-it-possible-to-log-the-response-data-in-nginx-access-log | |
access_log /path/to/host.access.log bodylog; | |
lua_need_request_body on; | |
set $resp_body ""; | |
body_filter_by_lua ' | |
local resp_body = string.sub(ngx.arg[1], 1, 1000) | |
ngx.ctx.buffered = (ngx.ctx.buffered or "") .. resp_body | |
if ngx.arg[2] then | |
ngx.var.resp_body = ngx.ctx.buffered | |
end | |
'; | |
location / { | |
proxy_pass https://foo.bar.com/; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment