4

So I have an nginx server running on Mac OSX and I am trying to create a symlink in my nginx www directory from somewhere else. In the browser I get the wonderful 403 Forbidden error. I have also tried chmod'ing my life away for the past few hours.

There doesn't seem to be anything on the stack about it. One thing concerns me is that I am not sure if symlinks are directly supported by ngninx on Mac.

Trying to use disable_symlink directive results in:

nginx: [emerg] unknown directive "disable_symlinks" in /usr/local/etc/nginx/nginx.conf:44`


Some info about my setup:
nginx -v : nginx version: nginx/1.4.2


To create the symlink I do the following:

cd /Users/levi/www
ln -s "/Users/levi/Desktop/.../client" "/Users/levi/www/client"


The error in the log:

[error] 11864#0: *7 open() "/Users/levi/www/client" failed (13: Permission denied), client: 127.0.0.1, server: _, request: "GET /client HTTP/1.1", host: "localhost"


Any help is much appreciated. Let me know if there's any more information I can give you.

Levi Roberts
  • 201
  • 1
  • 2
  • 9

2 Answers2

3

I just ran into something similar. Turns out one of the directories along the way to the target had too-restrictive permissions. chmod 755 $HOME fixed it in my case.

Falcon Momot
  • 24,975
  • 13
  • 61
  • 92
Dan Kegel
  • 31
  • 1
  • 1
    Just a warning; this means anyone with access to your machine (other users, SSH, etc) will be able to access your home folder and, potentially, anything private within it. – Nick Jul 05 '18 at 09:33
2

I can verify that symlinks with nginx work on the mac with nginx 1.2.7.

Symlink created as:

ln -s /Users/salpher/nginxtest /usr/local/opt/nginx/html/

Do you have any content in the 'client' directory? Directory index browsing is disabled by default and you will see a 403 forbidden if there is no index page and your url does not point at a particular content file.

If it's directory browsing that you're after you can enable that in your directory config with autoindex on;

    location / {
        autoindex on;
        root   html;
        index  index.html index.htm;
    }
Sam Alpher
  • 316
  • 1
  • 5
  • Yes, there are two files in the 'client' directory. Autoindex is turned on. I do not have an index file for the directory though or the root directive. I don't think that's creating the problem though. – Levi Roberts Dec 06 '13 at 05:00
  • Can't seem to edit my other comment. I tried adding the root directive and an index directive, neither and both did not fix the issue. I also found that I get the same "permission denied" message when trying to point '/client' in the nginx config to the original 'client' directory. – Levi Roberts Dec 06 '13 at 05:21
  • Do you also get a 403 when your URL points at an html file or something other than a directory? – Sam Alpher Dec 06 '13 at 12:52
  • Yes I do. For example when trying to go to http://localhost/client/somefile.html – Levi Roberts Dec 06 '13 at 13:18
  • If you haven't already you might check out http://serverfault.com/questions/218583/403-forbidden-error-on-mac-osx-apache-and-nginx . Sounds similar. Also, how did you install nginx? Was it a binary installation or did you grab the code and compile? If it was a binary installation where did it come from? For reference my test setup came from a brew installation. – Sam Alpher Dec 06 '13 at 14:25
  • I honestly can't remember, but if I had to take a guess it would be that I installed it with homebrew. Nothing fancy just 'brew install nginx'. But i'll take a look at that link. – Levi Roberts Dec 06 '13 at 18:27
  • It seems that was the issue. By default in OSX the Desktop permissions for 'everyone' are set to 'No Access'. In finder, then clicking info, sharing & permissions - set 'everyone' to read only. Fixed the issue. I am sure this is a major security issue. If you could write up a detailed answer on how to properly allow this directory to be used by the nginx user (by default 'nobody') from the command line, I will give you the answer. – Levi Roberts Dec 06 '13 at 19:56