as a browser sends it; the result updates as you type
Location blocks 0
in the order they are in the configResult
⬆ Import an nginx config
Comments, quotes and nested braces are read as nginx reads them. Nested locations, if { }, named locations and includes are listed and left out.
⚡ Test many paths at once
Each is matched against the blocks above.
📋 Export as an nginx config
, quoted where nginx needs it. Check it with sudo nginx -t before reloading.
How nginx picks a location
- The path is cleaned up first. %XX codes are decoded (so
%2Fbecomes a real/),.and..are resolved, repeated slashes are merged, and the query string is set aside. Matching uses this path; a broken %XX code or a..above the top gets 400 Bad Request. - = exact: a block whose pattern is the whole path wins at once.
- Trailing slash: if a prefix block ending in
/passes requests on (proxy_pass and the like) and the path is that pattern without the/, nginx answers 301 to add it, without checking regexes. A block whose pattern is exactly the path stops this. - Longest prefix: of the plain and
^~prefixes that match, nginx remembers the longest. If it has^~, it wins and regexes aren’t checked. - Regexes (
~, and~*for any case) are tried in the order they appear; the first that matches wins. - Otherwise the remembered longest prefix wins. With no match at all, nginx serves files from the server’s root.
http://backend:3000), the request goes on exactly as the browser sent it. With a path, even just /, nginx replaces the matched prefix with that path, using the cleaned-up path, and %-encodes it again if the request had %XX codes. In a regex block proxy_pass can’t have a path: nginx -t refuses it.