Skip to content

Instantly share code, notes, and snippets.

@pcdinh
Forked from deltheil/nginx.conf
Created July 13, 2017 07:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pcdinh/93df092e083fb66570ed5d7599c4e6b0 to your computer and use it in GitHub Desktop.
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
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