nginx config_error ai_generated true

Wrong location block matched: regex takes precedence

ID: nginx/regex-location-order

Also available as: JSON · Markdown
80%Fix Rate
84%Confidence
3Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
1 active

Root Cause

Nginx location matching order causing wrong block to handle request.

generic

Workarounds

  1. 90% success Use exact match (=) for specific paths, prefix (^~) to skip regex
  2. 92% success Remember order: exact > prefix(^~) > regex > prefix

Dead Ends

Common approaches that don't work:

  1. Use regex for all locations 78% fail

    Performance impact, hard to debug

  2. Add if statements inside locations 82% fail

    nginx if is evil in location context