August 2017
Intermediate to advanced
278 pages
8h 53m
English
Just like traditional HTTP based configurations, we can also enable access logs for TCP load balancing. We can tailor the logs to suit specific applications, which may include fields such as the client IP address, bytes sent, and bytes received.
To use the stream logging, we firstly need to define a log format. Here's a basic configuration:
log_format basic '$remote_addr [$time_local] '
'$bytes_sent $bytes_received $session_time';
Then, we add the access_log directive to our server block:
server {
listen 7400;
access_log /var/log/nginx/tcp-access.log basic;
proxy_pass tcpapppool;
}
This basic log format then gives us an output like this:
1.2.3.4 [28/Dec/2016:22:17:08 +1000] 18 ...
Read now
Unlock full access