Created
June 4, 2012 07:57
-
-
Save deltheil/2867074 to your computer and use it in GitHub Desktop.
Hide sensitive GET parameters within nginx access logs thanks to the Lua module
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 { | |
log_format filt '$remote_addr - $remote_user [$time_local] "$_request" ' | |
'$status $body_bytes_sent "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
server { | |
location /login { | |
# `set` is provided by the Rewrite module | |
set $filter "password|secret"; | |
set_by_lua $_request ' | |
local filt = ngx.arg[1] | |
local req = ngx.arg[2] | |
return ngx.re.gsub(req, "((" .. filt .. ")=)[^&]+", "$1-FILTERED-") | |
' $filter $request; | |
access_log logs/access.log filt; | |
# ... | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi! This works for me: https://serverfault.com/questions/1046249/exclude-a-specific-query-parameter-from-being-logged-in-nginx