opyeb logscrub

Nginx access log format and field reference

2026-11-29 · 2 min read

One-line answer: the combined format writes one request as nine space-separated fields — the sixth is the status code and the number after the last quoted string is the response time.

The two default formats

Nginx's default access_log uses the combined format: client address, remote user, authenticated user, request time, request line, status, bytes sent, referer and user agent, in that order. Apache's combined log uses the same order, so one parser can read both.

The common format drops the referer and user agent at the end. It still appears on older configurations and on proxy appliances.

203.0.113.24 - - [29/Nov/2026:08:00:12 +0900] "GET /api/v1/orders/4821 HTTP/1.1" 200 1732 "https://shop.example.com/" "Mozilla/5.0"
Fields of the combined format
#VariableMeaning
1$remote_addrClient address; behind a proxy this may be the proxy
2$remote_userHTTP authenticated user, or -
3$time_localServer local time in brackets
4$requestMethod, path and query, protocol, in quotes
5$statusThree-digit response status
6$body_bytes_sentBody bytes, or -
7$http_refererPrevious page
8$http_user_agentClient string, which contains spaces

Fields teams add

Real logs usually add timing. $request_time is the seconds from receiving the request to finishing the response; $upstream_response_time is the time the backend took. Keeping both tells you whether Nginx or the backend is slow.

The format is set with log_format. Adding a field can break an existing parser, so give the new format a new name and keep both for a while.

log_format main_ext '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" "$http_user_agent" '
                    '$request_time $upstream_response_time';
access_log /var/log/nginx/access.log main_ext;

Reading status codes

2xx is success, 3xx a redirect, 4xx a client-side problem and 5xx a server or upstream problem. 499 is Nginx's own code for a client that closed the connection before the response. 502 means the upstream sent an invalid response, 504 that it exceeded the timeout.

Many 4xx responses are not an attack. A 404 can be an old link, a 401 an expired token, a 429 a working rate limit. The numbers only become meaningful when split by endpoint.

Codes you will see
CodeMeaningCheck first
200OKTrend of response time
301, 302MovedRedirect target and caching
400, 401, 403Request, auth, permissionClient release, token expiry
404No such pathRenamed links, asset paths
429Rate limitedLimit policy, client retries
499Client closedSlow response, mobile networks
502, 504Upstream error or timeoutBackend health, timeout settings

Where parsing goes wrong

The user agent contains spaces, so splitting on whitespace shifts every later field. Recognise the quoted strings first and treat each as one value. Empty referer and agent are normal and appear as -.

IPv6 clients arrive in the first field with colons and no brackets. A broken request line can leave only "-", so validate the status and path separately. Month names follow the server locale, so log with a fixed locale such as en.

What to remove before sharing

The first field is an IP address that can identify a person. Query strings often carry an e-mail address, session token or payment reference, and the referer can reveal an internal admin URL. The user agent narrows the device and browser enough to act as a fingerprint.

An incident review needs the path, status, response time and timestamp. Mask or pseudonymise the IP and query values, normalise numbers and UUIDs in the path, and the log remains useful without the original identifiers.

before:  GET /api/v1/users?email=minji.kim@example.com 200
after:   GET /api/v1/users?email=m***@example.com 200

Questions

How do I tell combined from common?

If the line ends with two quoted strings after the byte count, it is combined. If it ends right after status and bytes, it is common. The earlier fields are identical.

What is the difference between $request_time and $upstream_response_time?

$request_time covers the whole request inside Nginx; $upstream_response_time covers only the backend. A large first value with a small second points to client transfer or Nginx processing.

Sources

Every example here can be pasted into the workbench as it is.

Open the workbench