Welcome! Log In Create A New Profile

Advanced

$body_bytes_sent = 0

Posted by stopka 
$body_bytes_sent = 0
April 29, 2011 08:04AM
Стоит nginx 0.8.53 и php-fpm 5.3.6
Конфиг nginx (Весь кофиг не буду приводить, приведу отрывок):

log_format main
'$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent --->$body_bytes_sent<--- '
'"$http_referer" "$http_user_agent" '
'"$gzip_ratio"';

server {
listen 80;
server_name server.local;

access_log /www/server/www/logs/access.log main;
error_log /www/server/www/logs/error.log;


location ~* \.php$ {
root /www/server/www/htdocs/;

fastcgi_pass unix:/var/run/php-fpm.socket;

fastcgi_param SCRIPT_FILENAME /www/server/www/htdocs$fastcgi_script_name;
fastcgi_param HTTP_X_REAL_IP $remote_addr;
fastcgi_param BBBBBBB $body_bytes_sent;
include /etc/nginx/fastcgi_params;
}

location ~ /.svn/ {
deny all;
}
}

Все работает, но есть один нюанс. В access логах вижу значения $body_bytes_sent. Вполне себе корректное, а в PHP в $_SERVER['BBBBBBB'] вижу 0. С чем может быть это связано?
Re: $body_bytes_sent = 0
November 28, 2021 03:29PM
Аналогичная проблема.

в /etc/nginx/nginx.conf


http {
log_format requestbody '$remote_addr - $remote_user [$time_local] '
'"$request" $request_body $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
}

в /etc/nginx/sites-available/mydomain.com

server {
listen 443 ssl;
server_name mydomain.com;
ssl_certificate /etc/ssl/bundle.crt;
ssl_certificate_key /etc/ssl/private.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES256-SHA384;
client_body_in_single_buffer on; # я думал эта опция поможет исправить проблему пустого лога.
ssl_prefer_server_ciphers on;
location /bot-path/example {
access_log /var/log/nginx/bot.log requestbody; # имя формата из блока http в /etc/nginx/nginx.conf
return 200;
}
}

Однако в логах:
***.***.***.*** - - [28/Nov/2021:23:13:19 +0300] "POST /bot-path/example HTTP/1.1" 200 0 "-" "-"
Re: $body_bytes_sent = 0
November 28, 2021 06:18PM
Проблему решил c помощью https://stackoverflow.com/questions/17609472/really-logging-the-post-request-body-instead-of-with-nginx
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 104
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready