Keeping track of bandwidth for Monero RPC nodes

First, we must make a clear distinction between RPC traffic and P2P traffic. As a node operator you might think "wow my node is doing so much traffic WTF where are all these bytes coming from and going to". Well, this is actually due to your P2P port being exposed, which is port 18080. This document does not cover the monitoring of P2P traffic. This document is specifically for the RPC port which runs on 18081 (or 18089).

As Monero RPC traffic is HTTP, we can use nginx to reverse proxy and record bandwidth passing through. This implies that monerod's RPC port stays on localhost