-
-
Save pcdinh/93df092e083fb66570ed5d7599c4e6b0 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 hidden or 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