Debugging Nginx 403 Errors

I was having trouble today figuring out a 403 error today while setting up Nginx on my laptop.

It appears nginx needs read and execute permissions on all folders from the root to the file to be served. I thought I’d set the permissions appropriately, but I was actually only looking at the path from my home directory to the files being served.

It turned out to be super easy to debug this with iname -om <path>, which will show the permissions for every node in a given path:

$ namei -om ~/code/nginx-text
f: /home/cgag/code/nginx-test
 drwxr-xr-x root root  /
 drwxr-xr-x root root  home
 drwx------ cgag users cgag
 drwxr-xr-x cgag users code
 drwxr-xr-x cgag users nginx-test

Super easy assuming you somehow know this program and flag combination exists.