Nginx Location Match Simulator
Paste location blocks and a URI to see which block wins, with the full decision trace.
Nginx configuration
11 lines · 150 chars · 3 locationsMatching verdict
line 5Winning location
~*\.(css|js)$ (line 5)
URI used: /static/app.css
- exact/static/app.css — no exact match
- prefix/static/app.css — /static/ (line 2, 8 bytes), / (line 8, 1 bytes)
- regex~* \.(css|js)$ — match (line 5)
- finalfirst matching regex — winner: line 5
Directives in the winning block
expires 30d
Details
A diagnostic tool for nginx location precedence. It parses server blocks and bare location lists (including quoted and brace-containing regex patterns), normalizes the request URI the way nginx does, then applies exact, longest-prefix, ^~ short-circuit and regex-in-configuration-order phases. Each phase is traced with the candidates considered and the reason for skipping regexes. Named locations are excluded, includes are flagged, and common PCRE constructs are translated; any degraded verdict is called out next to the winner. Configurations stay in the browser.
More examples
Longest prefix wins
location /docs { }
location /docs/api { }
location / { }For /docs/api/v1 the trace shows /docs/api selected over the shorter prefixes.
^~ short-circuit
location ~ \.php$ { }
location ^~ /static/ { }For /static/index.php the regex phase is skipped because the caret prefix already won.
Exact health check
location = /health { return 200; }
location ~ /heal { return 418; }An exact match wins before any regex is tested, even with a query string on the URI.
Examples
Exact beats regex
location = /health { }
location ~ /heal { } — /health?x=1winner: location = /healthThe exact phase runs first and short-circuits regex evaluation.
Caret short-circuit
location ~ \.php$ { }
location ^~ /static/ { } — /static/index.phpregex phase skippedThe longest ^~ prefix wins before any regex is tried.
Encoded path
/x%2f%2fy/x/yDecoding happens before slash merging, matching nginx's $uri normalization.
About this tool
Nginx Location Match Simulator answers one question precisely: which location block handles this request URI? Paste a server block or a bare list of locations, enter a URI, and the tool walks nginx's documented precedence with a trace of every step.
Exact `=` locations win immediately. Among plain prefixes and `^~` prefixes the longest matching prefix is selected; a `^~` winner skips regular expressions entirely. Otherwise `~` and `~*` regexes are tried in configuration order and the first match wins, falling back to the longest prefix. Skipped candidates and their reasons appear in the trace.
Before matching, the URI is split from its query string, percent-decoded, slash-merged and dot-segment-resolved, mirroring the normalized `$uri` nginx uses. Traversal above root becomes a 400 outcome. Everything runs locally; pasted configuration never leaves the browser.
What this tool does not do
- Nested locations are reported but treated as a simplified continuation rather than fully recursive matching.
- include directives cannot be followed, so included locations are absent from the candidate set.
- rewrite and try_files directives inside a winning block are displayed but not executed.
- JavaScript RegExp is used after a small PCRE translation layer; exotic PCRE may diverge.
- Configs and URIs stay in the tab; nothing is uploaded or persisted.
How to use this tool
Paste the config
Add a server block or just the location blocks. Quoted patterns and regexes containing braces are parsed correctly; comments are ignored.
Enter a request URI
Provide an absolute path such as /static/app.css?x=1. The query string is shown but excluded from matching.
Set normalization
Toggle percent decoding and slash merging. The config's own merge_slashes off directive is respected by default.
Read the decision
The verdict card names the winning block and its line. The ordered trace shows exact, prefix, regex and final phases with skipped regexes called out.
Check the caveats
Duplicate prefixes, includes, nested locations, invalid if placement and untranslatable regexes are reported, and the verdict is marked degraded when needed.
Use cases
Debug static-route bypass
Find out why a regex never sees requests already captured by a ^~ prefix.
Audit a server block
Check a large pasted config for duplicate prefixes, includes and dead regexes.
Learn precedence
Compare exact, prefix and regex locations with an explicit trace for each request.
Handle encoded URIs
See how decoding and slash merging change the URI before matching.
Location modifiers
| Modifier | Meaning |
|---|---|
| = /path | Exact match; wins immediately over everything else |
| (none) /path | Plain prefix; longest matching prefix is remembered |
| ^~ /path | Prefix that short-circuits regex evaluation when it is longest |
| ~ regex | Case-sensitive regular expression, first match in config order wins |
| ~* regex | Case-insensitive regular expression |
| @name | Named location used by try_files/error_page; excluded from matching |
Query strings are split off before decoding; nginx matches locations against the normalized path only.
Common mistakes
Mistake:Assuming regexes are tried before prefixes.
Fix:nginx finishes the prefix phase first; a regex only wins if no ^~ prefix took the URI.
Mistake:Treating equal-length prefixes as ambiguous.
Fix:Only one distinct prefix of a given length can match a URI; the tool warns about identical duplicated prefixes instead.
Mistake:Including the query string in a location pattern.
Fix:nginx matches locations against the path only; the query is displayed as a note.
Mistake:Expecting full PCRE support.
Fix:Common PCRE constructs are translated; anything else is skipped with a degraded-verdict warning.
Mistake:Forgetting that includes are not followed.
Fix:Included locations are not present in the pasted text, so the tool warns that the candidate set may be incomplete.
Frequently asked questions
Which wins: a prefix or a regex location?
nginx first looks for an exact (=) match, then remembers the longest matching plain or ^~ prefix. If that prefix has ^~, regex evaluation is skipped and the prefix wins. Otherwise regular expressions are tried in configuration order; the first match wins, and if none match the remembered longest prefix is used.
What does ^~ do exactly?
^~ marks a prefix location as terminal for matching purposes: when it is the longest matching prefix, nginx does not test any ~ or ~* regex locations at all. The trace spells this out with the list of regexes that were skipped.
Are regexes tried in configuration order?
Yes. The first ~ or ~* pattern that matches the normalized URI wins, so moving a broad regex above a narrow one changes the result. The trace lists each regex in the order it was tried.
What happens with duplicate prefixes?
Two identical prefix locations are a configuration error in nginx and the simulator reports it. Distinct prefixes can never be ambiguous for a single URI: only one prefix of a given length can match it.
Does the query string affect matching?
No. nginx splits the query arguments off the raw URI before location matching. The simulator shows the query as a note but matches only against the normalized path.
Is my nginx configuration uploaded?
No. Parsing, normalization and matching happen entirely in your browser tab. Configurations often reveal internal infrastructure, so nothing is uploaded, logged or persisted.
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.gitattributes Generator
Build .gitattributes rules for line endings, Git LFS, GitHub linguist marks and merge drivers — with a one-line explanation for every rule.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
A/B Test Sample Size Calculator
Compute required sample size per variant and test duration from baseline conversion rate, minimum detectable effect, alpha and power.
ABA Routing Number Validator
Validate 9-digit US ABA routing numbers with 3-7-1 Mod-10 breakdown.