logging variables -- $bytes_sent .. where is $bytes_read ?

Valentin V. Bartenev vbart at nginx.com
Sat Apr 18 02:06:20 UTC 2015


On Saturday 18 April 2015 11:23:54 jb wrote:
> gotcha, I saw the discarded body thing in the debug log. ok thanks,
> um, how do you proxy_pass to nginx itself ?
> 
> can you give an example ?
> just proxy_pass http://127.0.0.1/
> and proxy_pass_request_body off
> 
> what about my return 200 "$content_length bytes" line still keep that?
> 
[..]

events {}

http {
   log_format  lengths  $request_length;

   server {
       location / {
           proxy_pass http://unix:nginx.sock:;
           proxy_pass_request_body off;

           proxy_set_header X-Response "$content_length bytes";
           proxy_set_header Content-Length "";

           access_log  logs/lengths.log  lengths;
       }
   }

   server {
       listen unix:nginx.sock;
       return 200 $http_x_response;
   }
}

% telnet 127.0.0.1 8000
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
POST / HTTP/1.0
Content-Length: 1000

bbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbb 
bbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbb
^]
telnet> close
Connection closed.
% cat logs/lengths.log      
145

--
wbr, Valentin V. Bartenev



More information about the nginx mailing list