요청 본문을 조건부로 기록하려면 nginx를 가져 오는 데 문제가 있습니다. 로그인 자격 증명을 기록하지 않으므로 URI가/로그인 URI가 아닐 때 올바르게 트리거되는지도가 포함되었습니다.
client_body_in_single_buffer on
fastcgi_pass php_cgi
echo_read_request_body
그러나 그 중 어느 것도 도움이 보이지 않는다하여 제안 유사한 게시물의 숫자가 될 것 같다. 어떤 아이디어? 아래는 현재 구성입니다. $scrubbed_request
가 log_format 라인에 $request_body
로 교체 할 경우, 우리는 모든 요청 몸을 캡처 않는
map $request_uri $log_body {
~/login 0;
default 1;
}
log_format filter '$remote_addr - $remote_user [$time_local] '
'"$request" $status $request_time $upstream_response_time "$scrubbed_request"';
server {
listen 443 ssl;
server_name localhost;
ssl_certificate /etc/ssl/site.crt;
ssl_certificate_key /etc/ssl/site.key;
access_log /var/log/nginx/site.log filter;
location /branch/dev/v2/ {
set $scrubbed_request 'NOT LOGGED';
if ($log_body) {
set $scrubbed_request $request_body;
}
rewrite /branch/dev/(.*) /$1 break;
proxy_pass http://127.0.0.1:3001;
}
location /branch/dev/ {
rewrite /branch/dev/(.*) /$1 break;
proxy_pass http://127.0.0.1:4001;
}
}
참고. 이로 인해 set
문이 예기치 않은 방식으로 request_body
을 어떻게 든 소비한다고 생각합니다.
내 요청 본문이 'abcdef'와 같은 작은 문자열 일 경우 어떻게'client_body_in_single_buffer' 도움을 줍니까? 그 문자열은 64 비트 인스턴스에 대해 프로비저닝 된 16K 버퍼에 쉽게 맞아야 할 것처럼 보입니다. 내가 놓친 게 있니? – Justin
@ Justin 요청 본문의 크기를 언급하지 않았습니다. 따라서 크기가 괜찮 으면'set'을 사용하지 말아야합니다. 'set' 지시어는 nginx가 본문 읽기를 시작하기 전에 작동하는 다시 쓰기 모듈의 일부입니다. – VBart