November 26, 2026
Anatomy of an HTTP Request (Part 7): Static vs.
In Part 6, our HTTP request entered Layer 2 and arrived at the web server (Nginx, Apache, or IIS). We looked at how server banners…

By Sahil
4 min read
Anatomy of an HTTP Request (Part 7): Static vs. Dynamic Routing, Slash Mismatches, and Path Confusion
In Part 6, our HTTP request entered Layer 2 and arrived at the web server (Nginx, Apache, or IIS). We looked at how server banners, directory listings, and exposed metadata files leak critical information before application code even executes.
In Part 7, we examine the core routing decision the web server makes the moment it reads the request path: should this URL be served as a static file from disk, or forwarded dynamically to the application runtime?
The Reference Request
We continue tracing our exact request as it enters the web server routing block:
POST /api/users/15/profile HTTP/1.1
Host: app.target.com
Cookie: session=abc123
Content-Type: application/json
X-Forwarded-For: 1.2.3.4
{"name": "Sahil", "role": "user"}POST /api/users/15/profile HTTP/1.1
Host: app.target.com
Cookie: session=abc123
Content-Type: application/json
X-Forwarded-For: 1.2.3.4
{"name": "Sahil", "role": "user"}Component 2.2: Static vs. Dynamic Routing
Where It Lives and What It Does
Routing happens inside the web server configuration file before the backend application ever sees the request. Based on the URL path, the web server splits traffic into two distinct execution paths:
• Static routing: The web server reads a file straight from the server machine's own local storage disk (for example, /var/www/html/static/app.js) and streams it directly over the socket. No application code executes, and no database query runs. Everything happens entirely on the server's filesystem. • Dynamic routing: The web server acts as a proxy and forwards the request to an application runtime such as Node.js, PHP, Python, or Java. The runtime executes business logic, queries databases, and generates a fresh response.
In an Nginx configuration, that split looks like this:
location /api/ {
proxy_pass http://localhost:3000;
}
location /static/ {
root /var/www/html;
}location /api/ {
proxy_pass http://localhost:3000;
}
location /static/ {
root /var/www/html;
}When POST /api/users/15/profile arrives, it matches location /api/ and forwards dynamically to Node.js on port 3000. When GET /static/app.js arrives, Nginx reads /var/www/html/static/app.js directly from disk and returns it without Node.js ever touching the request.
Three Routing Misconfigurations That Create Vulnerabilities
1. Wrong File Type Routed as Static or Dynamic
Security breaks whenever the web server applies the wrong handler to a file extension:
• Dynamic code served as static text (Information Disclosure): If a configuration file such as config.php sits inside a directory configured to serve static files, Nginx or Apache returns the raw file contents as plain text rather than executing the script. Anyone requesting /config.php downloads the unexecuted source code along with hardcoded database passwords and API secrets:
<?php $db_pass = 'secret'; $db_user = 'admin'; ?><?php $db_pass = 'secret'; $db_user = 'admin'; ?>• Static upload folder configured to execute scripts (Remote Code Execution): The inverse mistake occurs when a directory intended strictly for static user uploads (/uploads/) is configured to pass .php files to an execution interpreter. If an attacker uploads shell.php containing <?php system($_GET['cmd']); ?> and requests /uploads/shell.php?cmd=whoami, the server executes the payload and returns command output.
2. Trailing Slash Mismatch Causing Path Confusion
A single missing forward slash in a reverse proxy rule silently rewrites the URL path before it reaches the backend application.
Compare a properly matched configuration against a mismatched one:
# Properly matched slashes
location /api/ {
proxy_pass http://localhost:3000/api/;
}
# Trailing slash mismatch
location /api {
proxy_pass http://localhost:3000/;
}# Properly matched slashes
location /api/ {
proxy_pass http://localhost:3000/api/;
}
# Trailing slash mismatch
location /api {
proxy_pass http://localhost:3000/;
}In both cases, the client sends the exact same HTTP request:
POST /api/login HTTP/1.1
Host: app.target.com
Content-Type: application/json
Cookie: session=abc123
{"email": "sahil@test.com", "password": "test123"}POST /api/login HTTP/1.1
Host: app.target.com
Content-Type: application/json
Cookie: session=abc123
{"email": "sahil@test.com", "password": "test123"}With properly matched slashes, the backend receives POST /api/login. With the slash mismatch, Nginx matches the /api prefix without requiring a trailing slash, strips /api, and replaces it with /. The backend receives POST /login instead.
Applied to our reference request, POST /api/users/15/profile gets rewritten into POST /users/15/profile. If the backend application exposes an internal route /users/15/profile or /login that lacks public authentication checks because developers assumed it was unreachable from outside, external callers can now hit it directly.
3. Static Root Misconfiguration and Path Traversal
When static directories are mapped with a root directive such as:
location /uploads/ {
root /var/www;
}location /uploads/ {
root /var/www;
}Nginx appends the full request URI onto /var/www, resolving requests to /var/www/uploads/. When combined with URL normalization quirks and dot segments (..), path traversal payloads can occasionally step outside the intended folder boundary and read sensitive files on the host filesystem.
Practical Detection Probes
Because you cannot inspect the target's Nginx or Apache configuration file directly during a black box assessment, you infer routing behavior from response headers, path variations, and error signatures.
1. Distinguish Static vs. Dynamic Endpoints
Inspect the HTTP response headers on a clean request:
• Static response fingerprint: Includes caching and validator headers such as ETag, Cache-Control: max-age=3600, and Last-Modified, alongside static media types (text/javascript, text/css, image/png) and no Set-Cookie header. • Dynamic response fingerprint: Includes runtime headers such as Set-Cookie or X-Powered-By, returns dynamic payloads like Content-Type: application/json, and omits ETag and Last-Modified.
2. Probe for Unexecuted Source Files
Request common server side script paths directly (GET /config.php HTTP/1.1). If the response returns 200 OK with raw <?php tags visible in the body, the web server is routing script files as static text.
3. Probe for Slash Mismatches and Path Rewriting
Send subtle path variations alongside the normal endpoint and compare the responses:
Notice why POST /apilogin is revealing: a strict location /api/ block rejects /apilogin with 404 Not Found because there is no slash after api. By contrast, location /api without a trailing slash matches any path starting with /api, including /apilogin.
When testing traversal and rewriting probes, watch for three concrete visual signals in Burp Suite:
Error messages leaking the rewritten path: You send GET /api/../admin, and the backend responds with 404 Not Found and {"error": "Cannot GET /admin"} (or {"error": "route /login not found"}). The backend error reveals that Nginx resolved .. or stripped /api before forwarding.
From this point onwards Medium was not letting me to add anything, so I wrote the content in my Code Editor and added screenshots of content , so this article can continue in flow and structure.