Skip to content
Lesson: Web Access LogsSwitch
← Security Operations

Security investigations

Web Access Logs

Read web server access logs and use them to notice unusual requests.

An access log records requests a web server handled. It helps you debug problems and notice behaviour worth investigating on your own servers.

One line, field by field

The widely used "combined" format looks like this:

text
203.0.113.9 - - [03/Mar/2026:09:14:02 +0000] "GET /login HTTP/1.1" 200 1532 "-" "Mozilla/5.0"

In order: client address, identity (usually -), authenticated user, time, request line, status, size sent, referrer and user agent. nginx and Apache can both be configured differently, so check your log_format or LogFormat.

Default locations are /var/log/nginx/access.log for nginx, /var/log/apache2/access.log for Apache on Debian and Ubuntu, and /var/log/httpd/access_log on Fedora and RHEL.

Summarise

Busiest client addresses:

bash
$ sudo awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -3
    812 203.0.113.9
     95 198.51.100.4
     40 192.0.2.17

Paths returning 404:

bash
sudo awk '$9 == 404 {print $7}' access.log | sort | uniq -c | sort -rn | head

What to look for

  • Many 401 or 403 responses from one address, possibly password guessing or probing.
  • Many 404s for paths you do not have, typical of automated scanning.
  • A sudden jump in 5xx, often a fault in your application.
  • Large response sizes where you expect small ones.

These are leads, not proof. A busy address may be a monitoring tool or many people behind one shared gateway. A login form may answer failures with 200, so learn how your application behaves.

Know the limits

The user agent and referrer are sent by the client and can say anything. Behind a proxy or load balancer, the first field may be the proxy. X-Forwarded-For can be forged unless your server accepts it only from proxies you trust. Access logs usually do not contain request bodies.

Logs contain personal data and sometimes tokens in query strings. Restrict access, set a retention period, and send copies to another host so they survive trouble on this one.

Try it

Request an existing page and a missing one on a test server, then find both lines with tail. Run the two summaries above. Sharpen your pipelines in the streams and text lab.

Check your understanding

Web Access Logs

All 4 sections · no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.