特定のクエリパラメータを Nginx のログに記録しないようにしますか?

特定のクエリパラメータを Nginx のログに記録しないようにしますか?

URI 内の特定のクエリ パラメータを Nginx アクセス ログに記録されないようにすることは可能でしょうか?

現在の構成は次のとおりです。

log_format  main  '$remote_addr - $remote_user [$time_local] $host "$request" '
                      '$status $body_bytes_sent $request_time "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

リクエストパスに関係なく、「緯度」パラメータをログから除外したい(または、できれば難読化したい)とします。除外できることはわかっています。全てクエリパラメータを「$request」を「$request_method $uri」などに変更すると、全て私が望んでいるものではないパラメータです。

アップデート:

私はGET /index.html?latitude=43.4321&otherkey=value HTTP/1.1次のように難読化したいです:GET /index.html?latitude=******&otherkey=value HTTP/1.1

答え1

GET /index.html?key=latitude&otherkey=value HTTP/1.1
なる GET /index.html?key=***&otherkey=value HTTP/1.1

コードは次のとおりです:

log_format  main  '$remote_addr - $remote_user [$time_local] $host "$customrequest" '
                      '$status $body_bytes_sent $request_time "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
map $request $customrequest {
        ~^(.*)(latitude)(.*)$   "$1***$3";
        default                 $request;
}

次のように複数のキーワードを追加できます。~^(.*)(latitude|dell|inspiron)(.*)$

編集:
コメントで指定後、正規表現を変更する必要があり
GET /index.html?latitude=5570&otherkey=value HTTP/1.1ます。
GET /index.html?latitude=***&otherkey=value HTTP/1.1

map $request $customrequest {
        ~^(.*)([\?&]latitude=)([^&]*)(.*)$   "$1$2***$4";
        default                 $request;
}

関連情報