Safeguard
Security Guides•

Do nginx access logs record secrets in query strings?

The default nginx combined log format records the full request line, query string included, plus the Referer. Learn what that exposes and how to log less.

Safeguard Security Team
3 min read

Yes. The predefined combined format logs the full request line, which includes the query string, and the Referer header. It does not log the Authorization header unless you add it. Any token placed in a URL will therefore end up in your access logs.

What the default format contains

The nginx log module documents the predefined combined format like this:

log_format combined '$remote_addr - $remote_user [$time_local] '
                    '"$request" $status $body_bytes_sent '
                    '"$http_referer" "$http_user_agent"';

Variable by variable:

VariableContainsSensitivity
remote_addrClient IPPersonal data in many regimes
remote_userUsername from HTTP authenticationIdentifies a person
requestMethod, full URI with query, protocolMay hold tokens, emails, reset codes
http_refererThe Referer headerCan carry the previous page's URL and query
http_user_agentBrowser stringLow

The Authorization header and other request headers are not in the format. Logging them takes a custom format that uses the http_authorization variable, so do not add that variable.

Where the risk really is

Two fields carry most of the danger. The request line includes whatever the client put after the question mark: API keys, password reset tokens, magic login links, signed download URLs. The Referer field can include the same kind of values from the page the user came from.

Once written, those values sit in a file, are shipped to a central store, and are readable by everyone with log access. The secret has been copied three or four times before anyone reviews it.

Steps to log less

  1. Search recent logs for patterns such as token=, key=, secret=, code= and password=. Count the hits.
  2. Fix the clients. Credentials move into the Authorization header or a request body. See bearer token in header or query string.
  3. For endpoints that must carry a token in the URL, such as a one-time reset link, log a separate custom format for that location that records the path without the query. In nginx, the uri variable holds the path without arguments, while args holds the query.
  4. Decide whether you need the Referer at all. If not, remove it from your custom format.
  5. Short retention on raw access logs, longer retention on a reduced version. See set log retention by data class.
  6. Add a redaction layer in your shipper as a second defence.

A sample reduced format

log_format reduced '$remote_addr [$time_local] "$request_method $uri" '
                   '$status $body_bytes_sent "$http_user_agent"';

This keeps method, path, status and size, which is enough for most security triage, and drops the query string and Referer. You lose some debugging detail, so test with your support team before you roll it out. The nginx page defines the variable names above, but you should confirm uri and args behaviour against your nginx version.

Quick check

Does the combined format log the Authorization header?

No. It records Referer and User-Agent from request headers. You would have to add the Authorization variable yourself, and you should not.

Is the IP address in the log personal data?

Often yes. See is an IP address in a log personal data under GDPR.

Safeguard scans dependencies and builds SBOMs, so you can see which web server and proxy components you ship. Try a free scan at gold.safeguard.sh/scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.