nginx -t passing ≠ website accessible.
Our own backend address /admin Long-term bad: 301 redirects to /admin/, and that’s a real directory with no index file—browsers show a blank 403 page. Syntax checks pass completely, yet logs are flooded with "directory index is forbidden". This tool gives you a curl health-check script that prints status codes hop-by-hop, plus nginx fix snippets for corresponding failures.
—
—
| Phenomenon | Most common root cause | How to verify |
|---|---|---|
| 301 → with trailing slash → 403 | The path name is a real directorytry_files $uri $uri/ Triggers directory redirection, but the directory contains no index file. | ls /var/www/site/this-directory Check whether index.html exists |
| Too many redirects | Mutual nesting of exact-match location 301 redirects and try_files internal redirects | Check in the script whether the Location header redirects back to the previous URL. |
| Clean URL returns 404, but .html version works normally. | Avoid redundant try_files $uri.html | Add try_files $uri $uri.html $uri/ =404; |
| .html is 301-redirected to an incorrect clean URL. | Used in location if Perform regex validation, coverage achieved $1 Capture Group | Move the if condition out of this location block, or use map instead |
| A certain prefix path does not match the expected location. | Regex location takes precedence over ^~ Hit before prefix (^~ Overrides regex, but ordinary prefix locations won’t) | nginx -T | grep -n location Check order and type |
| 403 and the log says "forbidden by rule". | deny rules or file permissions | Check the specific line in the error log—don’t guess. |
1 · Admin URL consistently returns 403./admin Redirected to 301 /admin/, while /admin/ It is a real directory (containing data/), with no index file → 403 white screen. Only /admin.html Accessible.
2. Rewriting is internal rewriting, not adding an index.rewrite ^/admin/?$ /admin.html last; Ensure both /admin and /admin/ resolve directly to the file, with login protection unchanged.
3 · Syntax checks cannot detect this type of issue.nginx -t Syntax-only check: it flags zero errors for redirect chains, directory indexing, and other logic issues. After changes, always verify with real HTTP requests—check status codes and redirect counts.
4 · Paired testing/x and /x/ These are two distinct URIs; matching rules may differ, and both must return 200.