Does a Threat Model Survive Contact with Your Reverse Proxy Logs?
Your threat model is a set of guesses about who will attack you and how. Your reverse proxy access log is the only place where those guesses get tested against reality. Most people write the first and never open the second.
This is a short procedure for putting the two side by side. It assumes nginx with the default combined log format, but the ideas carry over to Caddy, Traefik or HAProxy.
Write the assumptions down as testable claims
A threat model sentence like "only I use the admin panel" is vague. Turn it into something a log can contradict. Here are some examples:
- Only my own IP, or my VPN's address, ever gets a 200 from
/admin. - Every request arrives with one of my real hostnames in the Host header.
- Nobody requests paths my application does not have.
- Nobody sends methods other than GET, POST and HEAD.
- The client address in the log is the real client, not the proxy.
Each of those is a one-line query. If a claim is false, you have found a gap in the model, or in the config that was supposed to enforce it.
Start with what the log already shows
In the combined format, awk splits a line so that field 1 is the client address, 7 is the path and 9 is the status. That is enough for a first look.
# paths that 404 most often
awk '$9 == 404 {print $7}' access.log | sort | uniq -c | sort -rn | head -20
# who got a 200 on the admin area
awk '$7 ~ /^\/admin/ && $9 == 200 {print $1}' access.log | sort | uniq -c
The first command is usually humbling. Expect /.env, /wp-login.php, /.git/config, /actuator/health and friends, probably on a server that has never run any of them.
That tells you something about the attacker in your model. The realistic adversary for most small servers is a bulk scanner, not a person who picked you. If your model spent pages on a motivated targeted attacker and none on "someone finds a forgotten file by guessing", the log has just reordered your priorities.
Quick detour: how did they find you so fast?
A new hostname often gets probed within minutes. That surprises people until they remember that public certificates are logged in Certificate Transparency logs, and anyone can watch those feeds. Issuing a Let's Encrypt certificate for secret-admin.example.org announces that name to the world.
So "nobody knows the hostname" is not a control. If the model leans on it, move that item to "obscurity only" and put a real control behind it, such as a client certificate, a VPN or an IP allowlist.
Check the Host header, not just the path
The default format does not record which hostname was requested. Add it. This single change catches more wrong assumptions than any other.
log_format modelcheck '$remote_addr [$time_local] $host "$request" '
'$status $body_bytes_sent "$http_user_agent"';
access_log /var/log/nginx/access.log modelcheck;
Now count requests by host:
awk '{print $3}' access.log | sort | uniq -c | sort -rn
You will see your real names, and probably a bare IP address too, plus the odd hostname you never configured. Those come from scanners walking IP ranges and from old DNS records pointing at you.
Whatever answers those requests is your default server block. If it quietly serves your main site or an internal app, then virtual host selection is part of your attack surface. Give it an explicit job: reject the connection.
server {
listen 80 default_server;
listen 443 ssl default_server;
ssl_reject_handshake on;
return 444;
}
Hang on, what is 444? It is an nginx-specific status that is never sent to the client: nginx just closes the connection. It does not appear in any RFC, which is why you will not find it in the usual status code lists. For the default block it is exactly right. The ssl_reject_handshake line stops the TLS handshake from completing, so the scanner does not even receive your certificate.
Test the "only me" claims against status codes
If the model says an area is restricted, the log should show 403 or 401 for everybody else. Look for the opposite:
awk '$7 ~ /^\/admin/ {print $1, $9}' access.log | sort | uniq -c | sort -rn | head
Read it for two things. Any 200 from an address that is not yours is a failed assumption, and you should find out why before doing anything else. A long run of 401s from one address is a different problem: it is credential guessing, which means your model needs a rate limit or lockout for that route.
Also check 400 responses and odd methods:
awk '$9 == 400' access.log | head
awk '{print $6}' access.log | sort | uniq -c | sort -rn
Malformed requests that produce 400 are often smuggling or parser probes. A stream of "CONNECT or "PROPFIND methods against a site that uses neither tells you someone is testing whether you run an open proxy or a WebDAV server. Confirm the answer is no, and that the 4xx you return is the same one every time.
Is the address in the log even real?
If every line shows 127.0.0.1 or your CDN's range, every claim above about "which IP" is meaningless. A second proxy in front of nginx rewrites the source address, and a backend that trusts X-Forwarded-For blindly lets any client choose its own.
The check is simple. From outside, send a request with a forged header and see what the log records:
curl -s -o /dev/null -H 'X-Forwarded-For: 203.0.113.9' https://example.org/
tail -n 1 /var/log/nginx/access.log
If 203.0.113.9 appears as the client, something upstream is trusting a header it should not. Fix that before you trust any IP-based line in this article, including the allowlist tests above.
What the log cannot tell you
Access logs show requests, not outcomes. A 200 on /.env proves something was served; it does not tell you whether the file held secrets. A scan that produces only 404s tells you nothing about what a human tried by hand with a browser and a fresh IP address. And TLS-level failures, like handshake errors, land in the error log, not the access log, so check both.
There is also a cost to doing this. Client IP addresses are personal data under UK GDPR, and a log you keep for security analysis still needs a sensible retention period. Keep what the checks need, rotate it, and do not let the evidence pile up forever because it might be useful.
Updating the model
Run the checks once a month, or after any change to the proxy config. Each failed claim becomes one of three things: a config fix, a new line in the threat model, or a note that you are knowingly accepting the risk.
The useful outcome is not a clean log. It is a threat model whose assumptions you have actually watched hold or break, which is a rarer thing than a well-written one.