RunTheTests
/

Nginx / Apache Config Explainer

Read an nginx or Apache block and see what each line really does.

What you paste

Parsed in your browser — never uploaded

How this reads your output

Each line is matched against the directives that turn up most often in real configurations, and explained with the behaviour that actually catches people rather than a restatement of the manual. Alongside that, the whole block is checked for omissions: a proxy without a Host header, a reverse proxy without the forwarded protocol header, TLS with no explicit protocol list. Those are not syntax errors, so the configuration loads and works until the specific situation each one causes.

What the results mean

Worth a second look
Directives whose behaviour differs from what most people assume, such as the trailing slash on proxy_pass or how add_header inheritance works.
Common omissions
Missing directives that cause real problems later. A reverse proxy without forwarded headers is the usual source of redirect loops.
Detected server
Whether the block reads as nginx or Apache, chosen by which directive vocabulary appears more often.

Common problems and fixes

A backend behind the proxy redirects in a loop
The backend cannot tell it is behind TLS termination, so it sees plain HTTP and issues a redirect to HTTPS, which arrives back as plain HTTP again. Set X-Forwarded-Proto and Host on the proxy, and configure the application to trust them. This is the single most common reverse proxy fault and it is entirely about headers.
Security headers disappeared from some responses
In nginx, add_header does not inherit: a single add_header inside a location block discards every add_header from the enclosing server block. Either repeat them in each block that adds one, or use the always variant with a module that merges them. The behaviour is documented and still surprises everyone.

Frequently asked questions

Why does a trailing slash on proxy_pass matter?

It changes what the backend receives. With a trailing slash, the matched location prefix is stripped before forwarding; without one, the full path is passed through. So a request to /api/users reaches the backend as /users in one case and /api/users in the other, which is a one-character difference producing a 404 that looks inexplicable.

How do I test a config before reloading?

Both servers offer a syntax check that names the file and line of any error. Run it every time before reloading, and prefer a reload over a restart: a reload applies changes without dropping existing connections, while a restart drops everything in flight.

Why does my nginx location block not match?

Matching order is not the order the blocks appear in. Exact matches win first, then the longest literal prefix, then regular expressions in file order, then the prefix match found earlier. That precedence catches almost everyone, and it is why adding a location above another often changes nothing.

Put this on your own site

Free to embed, no attribution required beyond the source link the frame carries itself. It runs entirely in your visitor's browser, sets no cookies and loads no third-party script.

Embed code
<iframe src="https://runthetests.com/embed/server-config-explainer/" width="100%" height="720" style="border:1px solid #e5e5e5;border-radius:8px" title="Nginx / Apache Config Explainer" loading="lazy"></iframe>

Preview it at https://runthetests.com/embed/server-config-explainer/. Embedded pages are marked noindex, so yours stays the canonical copy — not this one.

More in DevOps