I am using nginx as a websocket reverse-proxy. I would like to log the number of bytes sent (and ideally also received) over a websocket. If I use $body_bytes_sent
in log_format
, the entry in the access_log is always 0. As far as I can tell, a lot of data went through the websocket, so clearly $body_bytes_sent
does not include data sent over a websocket.
I tried to use $bytes_sent
, but it's just one or two hundred bytes (no matter how much data is sent over the websocket), which is clearly just the HTTP headers. I went through the list of available nginx variables, but I coulnd't find anything for me…
Any idea?
Best Answer
Problem solved!
The problem was that I was using an old version of nginx. With the latest one (1.14.0),
$body_bytes_sent
does log the amount of bytes sent over the websocket.