Created
June 10, 2013 13:43
-
-
Save bsstokes/5748792 to your computer and use it in GitHub Desktop.
Filter the password from a request in the nginx access log.
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
log_format filtered_log '$remote_addr - $http_host - $remote_user [$time_local] {$request_time} {$upstream_response_time} $upstream_addr' | |
'"$filtered_request" $status $body_bytes_sent ' | |
'"$http_referer" "$http_user_agent"'; | |
server { | |
root /home/ubuntu/password_test/www; | |
index index.html index.htm; | |
server_name password_test; | |
location / { | |
try_files $uri $uri/ /index.html; | |
#Strip password in access.log | |
set $filtered_request $request; | |
if ($filtered_request ~* (.*)(password)=[^&]*(.*)) { | |
set $filtered_request $1$2=[FILTERED]$3; | |
} | |
access_log /home/ubuntu/password_test/logs/access.log filtered_log; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment